From 1b99a3de6ebff127dce6bd47e99f2580e1f8fb59 Mon Sep 17 00:00:00 2001 From: Alejandro Gullon Date: Mon, 6 Jul 2026 15:32:28 +0200 Subject: [PATCH 1/2] feat: automate sosreport compatibility test with omc and omg tools Add Robot Framework test (OCP-61971) that verifies MicroShift sosreport output can be consumed by the omc and omg support tools. The test generates a sosreport, installs both tools, and validates that each can list pods, nodes, retrieve logs, and switch projects from the collected data. Extract shared SOS report keywords (Create Sos Report, Extract Sos Report, Cleanup Sos Report Directory) into a new sos-report.resource to eliminate duplication between test suites. USHIFT-7221 Co-Authored-By: Claude Opus 4.6 pre-commit.check-secrets: ENABLED --- test/resources/sos-report.resource | 53 +++++++ .../el10/releases/el102-lrel@otp-workloads.sh | 1 + .../el9/releases/el98-lrel@otp-workloads.sh | 1 + .../releases/el98-lrel@otp-workloads.sh | 1 + .../otp-workloads/sos-report-plugins.robot | 43 +----- .../sos-report-support-tools.robot | 131 ++++++++++++++++++ 6 files changed, 188 insertions(+), 42 deletions(-) create mode 100644 test/resources/sos-report.resource create mode 100644 test/suites/otp-workloads/sos-report-support-tools.robot diff --git a/test/resources/sos-report.resource b/test/resources/sos-report.resource new file mode 100644 index 0000000000..5d3e87139f --- /dev/null +++ b/test/resources/sos-report.resource @@ -0,0 +1,53 @@ +*** Settings *** +Documentation Keywords for creating, extracting, and cleaning up +... MicroShift SOS reports. + +Resource common.resource +Resource microshift-host.resource + + +*** Keywords *** +Create Sos Report + [Documentation] Create a MicroShift SOS Report using microshift-sos-report + ... and return the tar file path. + ... Requires ${SOS_REPORT_BASE_DIR} to be set in the importing suite. + ${rand_str}= Generate Random String 4 [NUMBERS] + ${sos_report_dir}= Catenate SEPARATOR=${EMPTY} ${SOS_REPORT_BASE_DIR}_ ${rand_str} + Command Should Work mkdir -p ${sos_report_dir} + ${output}= Command Should Work + ... /usr/bin/microshift-sos-report --tmp-dir ${sos_report_dir} + Should Contain ${output} Your sos report has been generated and saved in + ${sos_report_tarfile}= Command Should Work + ... find ${sos_report_dir} -type f -name "sosreport-*.tar.xz" + Should Not Be Empty ${sos_report_tarfile} + RETURN ${sos_report_tarfile} + +Create Sos Report With Profile + [Documentation] Create a SOS report with the specified profile and return the tar file path. + ... Requires ${SOS_REPORT_BASE_DIR} to be set in the importing suite. + [Arguments] ${profile} + ${rand_str}= Generate Random String 4 [NUMBERS] + ${sos_report_dir}= Catenate SEPARATOR=${EMPTY} ${SOS_REPORT_BASE_DIR}_ ${rand_str} + Command Should Work mkdir -p ${sos_report_dir} + Command Should Work + ... sos report --batch --clean --all-logs --profile ${profile} --tmp-dir ${sos_report_dir} + ${sos_report_tarfile}= Command Should Work + ... find ${sos_report_dir} -type f -name "sosreport-*.tar.xz" + Should Not Be Empty ${sos_report_tarfile} + RETURN ${sos_report_tarfile} + +Extract Sos Report + [Documentation] Extract SOS report from the tar file and return the extracted directory. + [Arguments] ${sos_report_tarfile} + ${sos_report_dir}= Command Should Work dirname ${sos_report_tarfile} + Command Should Work tar xf ${sos_report_tarfile} -C ${sos_report_dir} + ${sos_report_untared}= Command Should Work + ... find ${sos_report_dir} -maxdepth 1 -type d -name "sosreport-*" + Should Not Be Empty ${sos_report_untared} + RETURN ${sos_report_untared} + +Cleanup Sos Report Directory + [Documentation] Remove temporary SOS report files created during tests. + ... Requires ${SOS_REPORT_BASE_DIR} to be set in the importing suite. + Command Should Work rm -rf ${SOS_REPORT_BASE_DIR}_* + Command Should Work rm -rf /var/tmp/sosreport-* diff --git a/test/scenarios-bootc/el10/releases/el102-lrel@otp-workloads.sh b/test/scenarios-bootc/el10/releases/el102-lrel@otp-workloads.sh index 2aadbc69c9..27dbd07882 100644 --- a/test/scenarios-bootc/el10/releases/el102-lrel@otp-workloads.sh +++ b/test/scenarios-bootc/el10/releases/el102-lrel@otp-workloads.sh @@ -22,5 +22,6 @@ scenario_run_tests() { run_tests host1 \ suites/otp-workloads/sos-report-plugins.robot \ + suites/otp-workloads/sos-report-support-tools.robot \ suites/otp-workloads/kcm-flags.robot } diff --git a/test/scenarios-bootc/el9/releases/el98-lrel@otp-workloads.sh b/test/scenarios-bootc/el9/releases/el98-lrel@otp-workloads.sh index de9916ef8e..3322b1d929 100644 --- a/test/scenarios-bootc/el9/releases/el98-lrel@otp-workloads.sh +++ b/test/scenarios-bootc/el9/releases/el98-lrel@otp-workloads.sh @@ -22,5 +22,6 @@ scenario_run_tests() { run_tests host1 \ suites/otp-workloads/sos-report-plugins.robot \ + suites/otp-workloads/sos-report-support-tools.robot \ suites/otp-workloads/kcm-flags.robot } diff --git a/test/scenarios/releases/el98-lrel@otp-workloads.sh b/test/scenarios/releases/el98-lrel@otp-workloads.sh index 5b7696dcd5..5db324d0e1 100644 --- a/test/scenarios/releases/el98-lrel@otp-workloads.sh +++ b/test/scenarios/releases/el98-lrel@otp-workloads.sh @@ -22,5 +22,6 @@ scenario_run_tests() { run_tests host1 \ suites/otp-workloads/sos-report-plugins.robot \ + suites/otp-workloads/sos-report-support-tools.robot \ suites/otp-workloads/kcm-flags.robot } diff --git a/test/suites/otp-workloads/sos-report-plugins.robot b/test/suites/otp-workloads/sos-report-plugins.robot index 671d45d06e..a5a74a9518 100644 --- a/test/suites/otp-workloads/sos-report-plugins.robot +++ b/test/suites/otp-workloads/sos-report-plugins.robot @@ -9,6 +9,7 @@ Documentation Tests verifying MicroShift SOS report plugins are listed and Resource ../../resources/microshift-host.resource Resource ../../resources/microshift-process.resource Resource ../../resources/common.resource +Resource ../../resources/sos-report.resource Suite Setup Setup Suite Teardown Teardown @@ -134,45 +135,3 @@ Plugin Should Be Enabled [Documentation] Verify that the named plugin is not disabled in the sos report -l output. [Arguments] ${output} ${plugin_name} Should Not Match Regexp ${output} ${plugin_name}\\s+.*disabled - -Create Sos Report - [Documentation] Create a MicroShift SOS Report using microshift-sos-report - ... and return the tar file path. - ${rand_str}= Generate Random String 4 [NUMBERS] - ${sos_report_dir}= Catenate SEPARATOR=${EMPTY} ${SOS_REPORT_BASE_DIR}_ ${rand_str} - Command Should Work mkdir -p ${sos_report_dir} - ${output}= Command Should Work - ... /usr/bin/microshift-sos-report --tmp-dir ${sos_report_dir} - Should Contain ${output} Your sos report has been generated and saved in - ${sos_report_tarfile}= Command Should Work - ... find ${sos_report_dir} -type f -name "sosreport-*.tar.xz" - Should Not Be Empty ${sos_report_tarfile} - RETURN ${sos_report_tarfile} - -Create Sos Report With Profile - [Documentation] Create a SOS report with the specified profile and return the tar file path. - [Arguments] ${profile} - ${rand_str}= Generate Random String 4 [NUMBERS] - ${sos_report_dir}= Catenate SEPARATOR=${EMPTY} ${SOS_REPORT_BASE_DIR}_ ${rand_str} - Command Should Work mkdir -p ${sos_report_dir} - Command Should Work - ... sos report --batch --clean --all-logs --profile ${profile} --tmp-dir ${sos_report_dir} - ${sos_report_tarfile}= Command Should Work - ... find ${sos_report_dir} -type f -name "sosreport-*.tar.xz" - Should Not Be Empty ${sos_report_tarfile} - RETURN ${sos_report_tarfile} - -Extract Sos Report - [Documentation] Extract SOS report from the tar file and return the extracted directory. - [Arguments] ${sos_report_tarfile} - ${sos_report_dir}= Command Should Work dirname ${sos_report_tarfile} - Command Should Work tar xf ${sos_report_tarfile} -C ${sos_report_dir} - ${sos_report_untared}= Command Should Work - ... find ${sos_report_dir} -maxdepth 1 -type d -name "sosreport-*" - Should Not Be Empty ${sos_report_untared} - RETURN ${sos_report_untared} - -Cleanup Sos Report Directory - [Documentation] Remove temporary SOS report files created during tests. - Command Should Work rm -rf ${SOS_REPORT_BASE_DIR}_* - Command Should Work rm -rf /var/tmp/sosreport-* diff --git a/test/suites/otp-workloads/sos-report-support-tools.robot b/test/suites/otp-workloads/sos-report-support-tools.robot new file mode 100644 index 0000000000..c569735cc6 --- /dev/null +++ b/test/suites/otp-workloads/sos-report-support-tools.robot @@ -0,0 +1,131 @@ +*** Settings *** +Documentation Tests verifying MicroShift SOS report output can be consumed +... by the omc and omg support tools. +... +... Ported from Polarion: OCP-61971 +... USHIFT-7221 + +Resource ../../resources/microshift-host.resource +Resource ../../resources/common.resource +Resource ../../resources/sos-report.resource + +Suite Setup Setup +Suite Teardown Teardown + +Test Tags slow + + +*** Variables *** +${SOS_REPORT_BASE_DIR} /tmp/rf-test/sos-report-support-tools +${OMC_BINARY} /tmp/omc +${OMG_VENV} /tmp/omg-venv +${OMG_BINARY} /tmp/omg-venv/bin/omg +${MUST_GATHER_PATH} ${EMPTY} + + +*** Test Cases *** +Verify Omc Can Consume SOS Report + [Documentation] Verify that the omc tool can consume the SOS report + ... output under sos_commands/microshift and list pods, nodes, + ... and retrieve logs. + ... OCP-61971 + [Setup] Install Omc + Command Should Work ${OMC_BINARY} use ${MUST_GATHER_PATH} + ${pods_output}= Command Should Work ${OMC_BINARY} get pods -A + Should Contain ${pods_output} openshift-dns + ${nodes_output}= Command Should Work ${OMC_BINARY} get nodes + Should Not Be Empty ${nodes_output} + ${pod_name}= Get Pod Name From Tool ${OMC_BINARY} openshift-dns + ${container_name}= Get Container Name From Tool ${OMC_BINARY} openshift-dns + ${logs_output}= Command Should Work + ... ${OMC_BINARY} logs ${pod_name} -c ${container_name} -n openshift-dns + Should Not Be Empty ${logs_output} + Command Should Work ${OMC_BINARY} project openshift-dns + [Teardown] Uninstall Omc + +Verify Omg Can Consume SOS Report + [Documentation] Verify that the omg tool can consume the SOS report + ... output under sos_commands/microshift and list pods, nodes, + ... projects, and retrieve logs. + ... OCP-61971 + [Setup] Install Omg + Command Should Work ${OMG_BINARY} use ${MUST_GATHER_PATH} + Command Should Work ${OMG_BINARY} project + ${pods_output}= Command Should Work ${OMG_BINARY} get pods -A + Should Contain ${pods_output} openshift-dns + ${node_output}= Command Should Work ${OMG_BINARY} get node --show-labels + Should Not Be Empty ${node_output} + Command Should Work ${OMG_BINARY} get node -o wide + ${pods_json}= Command Should Work ${OMG_BINARY} get pods -A -o json + Should Contain ${pods_json} "items" + ${pod_name}= Get Pod Name From Tool ${OMG_BINARY} openshift-dns + ${container_name}= Get Container Name From Tool ${OMG_BINARY} openshift-dns + ${logs_output}= Command Should Work + ... ${OMG_BINARY} logs ${pod_name} -c ${container_name} -n openshift-dns + Should Not Be Empty ${logs_output} + ${projects_output}= Command Should Work ${OMG_BINARY} projects + Should Not Be Empty ${projects_output} + [Teardown] Uninstall Omg + + +*** Keywords *** +Setup + [Documentation] Set up all of the tests in this suite + Check Required Env Variables + Login MicroShift Host + ${sos_report_tarfile}= Create Sos Report + ${sos_report_extracted}= Extract Sos Report ${sos_report_tarfile} + VAR ${MUST_GATHER_PATH} ${sos_report_extracted}/sos_commands/microshift scope=SUITE + Verify Remote Directory Exists With Sudo ${MUST_GATHER_PATH} + +Teardown + [Documentation] Test suite teardown + Cleanup Sos Report Directory + Logout MicroShift Host + +Install Omc + [Documentation] Download and install the omc binary on the remote host. + ${arch}= Get System Architecture + IF "${arch}" == "aarch64" + Command Should Work + ... curl -sSfL --connect-timeout 30 --max-time 120 -o /tmp/omc.tar.gz https://github.com/gmeghnag/omc/releases/latest/download/omc_Linux_aarch64.tar.gz + Command Should Work tar xzf /tmp/omc.tar.gz -C /tmp omc + Command Should Work rm -f /tmp/omc.tar.gz + ELSE + Command Should Work + ... curl -sSfL --connect-timeout 30 --max-time 120 -o ${OMC_BINARY} https://github.com/gmeghnag/omc/releases/latest/download/omc_Linux_x86_64 + END + Command Should Work chmod +x ${OMC_BINARY} + Command Should Work ${OMC_BINARY} version + +Uninstall Omc + [Documentation] Remove the omc binary from the remote host. + Run Keyword And Ignore Error + ... Command Should Work rm -f ${OMC_BINARY} + +Install Omg + [Documentation] Install the omg tool via pip in a virtual environment on the remote host. + Command Should Work python3 -m venv ${OMG_VENV} + Command Should Work ${OMG_VENV}/bin/pip install o-must-gather + Command Should Work ${OMG_BINARY} --help + +Uninstall Omg + [Documentation] Remove the omg virtual environment from the remote host. + Run Keyword And Ignore Error + ... Command Should Work rm -rf ${OMG_VENV} + +Get Pod Name From Tool + [Documentation] Get the first pod name from the specified namespace using the given tool. + [Arguments] ${tool} ${namespace} + ${output}= Command Should Work + ... ${tool} get pods -n ${namespace} | tail -n +2 | head -1 | awk '{print $1}' + Should Not Be Empty ${output} + RETURN ${output} + +Get Container Name From Tool + [Documentation] Get the first container name from the first pod in the specified namespace. + [Arguments] ${tool} ${namespace} + ${output}= Command Should Work + ... ${tool} get pods -n ${namespace} -o json | python3 -c "import sys,json; print(json.load(sys.stdin)['items'][0]['spec']['containers'][0]['name'])" + Should Not Be Empty ${output} + RETURN ${output} From d5c0c9d01f653e9dd058d073fcfab0037af0af2d Mon Sep 17 00:00:00 2001 From: Alejandro Gullon Date: Mon, 6 Jul 2026 16:26:15 +0200 Subject: [PATCH 2/2] fix: use VAR assignment syntax for robocop compatibility Co-Authored-By: Claude Opus 4.6 pre-commit.check-secrets: ENABLED --- test/suites/otp-workloads/sos-report-support-tools.robot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/suites/otp-workloads/sos-report-support-tools.robot b/test/suites/otp-workloads/sos-report-support-tools.robot index c569735cc6..b2d12c4847 100644 --- a/test/suites/otp-workloads/sos-report-support-tools.robot +++ b/test/suites/otp-workloads/sos-report-support-tools.robot @@ -75,7 +75,7 @@ Setup Login MicroShift Host ${sos_report_tarfile}= Create Sos Report ${sos_report_extracted}= Extract Sos Report ${sos_report_tarfile} - VAR ${MUST_GATHER_PATH} ${sos_report_extracted}/sos_commands/microshift scope=SUITE + VAR ${MUST_GATHER_PATH}= ${sos_report_extracted}/sos_commands/microshift scope=SUITE Verify Remote Directory Exists With Sudo ${MUST_GATHER_PATH} Teardown