Skip to content
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
53 changes: 53 additions & 0 deletions test/resources/sos-report.resource
Original file line number Diff line number Diff line change
@@ -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-*
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions test/scenarios/releases/el98-lrel@otp-workloads.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
43 changes: 1 addition & 42 deletions test/suites/otp-workloads/sos-report-plugins.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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-*
131 changes: 131 additions & 0 deletions test/suites/otp-workloads/sos-report-support-tools.robot
Original file line number Diff line number Diff line change
@@ -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}