Skip to content

testsuite: add feature to run health check tool #10179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) 2025 SUSE LLC
# Licensed under the terms of the MIT license.

@scope_salt
@skip_if_github_validation
Feature: Health Check tool based on a supportconfig
A supportconfig generated from the Uyuni server
should be able to be parsed by Health Check tool.

Scenario: A supportconfig is taken from the server
When I generate a supportconfig for the server
Then I obtain and extract the supportconfig from the server

Scenario: Execute health check tool with server supportconfig
When I run "mgr-health-check -v -s /root/server-supportconfig/uyuni-server-supportconfig/ start" on "localhost"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I start health check tool with support config "/root/server-supportconfig/uyuni-server-supportconfig/" on "localhost"

Then I run "test $(podman ps | grep health-check | wc -l) == 4" on "localhost"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I check that Health check tool container is running


Scenario: I wait until health-check is ready
When I run "curl localhost:3000/api/health -o /dev/null" on "localhost" with timeout at most 10 seconds

Scenario: Health Check containers are healthy and running
When I run "curl -s localhost:9000 -o /dev/null" on "localhost"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using this step?

    And I wait until port "9000" is listening on "localhost" host

Then I run "curl -s localhost:3100 -o /dev/null" on "localhost"
And I run "curl -s localhost:9081 -o /dev/null" on "localhost"
And I run "curl -s localhost:3000 -o /dev/null" on "localhost"

Scenario: Health Check containers are exposing metrics
When I run "curl -s localhost:9000/metrics.json | python3 -c 'import sys, json; print(json.load(sys.stdin).keys())'" on "localhost"
Copy link
Member

@srbarrios srbarrios May 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's build a step definition for this please.

Then I check the health check tool metrics are exposed in "localhost"


Scenario: Cleanup: Remove health check tool
When I run "mgr-health-check stop" on "localhost"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, let's build some step for this

Then I run "test $(podman ps | grep health-check | wc -l) == 0" on "localhost"
And I run "rm /root/server-supportconfig -rf" on "localhost"
27 changes: 27 additions & 0 deletions testsuite/features/step_definitions/command_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,16 @@
_out, $fail_code = node.run(cmd, check_errors: false)
end

When(/^I run "([^"]*)" on "([^"]*)" with timeout at most (\d+) seconds$/) do |cmd, host, timeout|
node = get_target(host)
repeat_until_timeout(timeout: timeout.to_i, message: "Cmd '#{cmd}' failed") do
_output, return_code = node.run(cmd, check_errors: false)
break if return_code.zero?

sleep 1
end
end

Then(/^the command should fail$/) do
raise ScriptError, 'Previous command must fail, but has NOT failed!' if $fail_code.zero?
end
Expand Down Expand Up @@ -1056,6 +1066,23 @@
node.run('mgradm distro copy /tmp/tftpboot-installation/SLE-15-SP4-x86_64 SLE-15-SP4-TFTP', runs_in_container: false)
end

When(/I generate a supportconfig for the server$/) do
node = get_target('server')
node.run('mgradm support config', runs_in_container: false)
node.run('mv /root/scc_*.tar.gz /root/server-supportconfig.tar.gz', runs_in_container: false)
end

When(/I obtain and extract the supportconfig from the server$/) do
supportconfig_path = '/root/server-supportconfig.tar.gz'
test_runner_file = '/root/server-supportconfig.tar.gz'
get_target('server').scp_download(supportconfig_path, test_runner_file)
`rm -rf /root/server-supportconfig`
`mkdir /root/server-supportconfig && tar xzvf /root/server-supportconfig.tar.gz -C /root/server-supportconfig`
`mv /root/server-supportconfig/scc_* /root/server-supportconfig/test-server`
`tar xJvf /root/server-supportconfig/test-server/*supportconfig.txz -C /root/server-supportconfig`
`mv /root/server-supportconfig/scc_suse_*/ /root/server-supportconfig/uyuni-server-supportconfig/`
end

When(/I remove the autoinstallation files from the server$/) do
node = get_target('server')
node.run('rm -r /tmp/tftpboot-installation', runs_in_container: false)
Expand Down
1 change: 1 addition & 0 deletions testsuite/run_sets/secondary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@
- features/secondary/srv_cobbler_distro.feature
- features/secondary/srv_cobbler_buildiso.feature
- features/secondary/srv_cobbler_profile.feature
- features/secondary/srv_health_check_supportconfig.feature

## Secondary features END ##
Loading