diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/.packit.yaml b/.packit.yaml index c0adce2da..45bc30e40 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -28,13 +28,19 @@ jobs: - job: copr_build trigger: pull_request targets: - rhel-9: + rhel-9: &additional_repos additional_modules: "foreman-devel:el9" additional_repos: - https://yum.theforeman.org/releases/nightly/el9/x86_64/ - https://yum.theforeman.org/plugins/nightly/el9/x86_64/ + epel-9: *additional_repos module_hotfixes: true + - job: tests + trigger: pull_request + targets: + - epel-9 + srpm_build_deps: - wget - rubygems diff --git a/tests/rex/rex-uptime/main.fmf b/tests/rex/rex-uptime/main.fmf new file mode 100644 index 000000000..087895715 --- /dev/null +++ b/tests/rex/rex-uptime/main.fmf @@ -0,0 +1,3 @@ +summary: Run uptime command check on the provisioned guest +test: ./test.sh +framework: shell diff --git a/tests/rex/rex-uptime/test.sh b/tests/rex/rex-uptime/test.sh new file mode 100755 index 000000000..b757319be --- /dev/null +++ b/tests/rex/rex-uptime/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -euo pipefail + +echo "Running uptime check on the TMT guest" +uptime +echo "Uptime test on guest completed successfully." diff --git a/tests/rex/tmt/main.fmf b/tests/rex/tmt/main.fmf new file mode 100644 index 000000000..91b27804f --- /dev/null +++ b/tests/rex/tmt/main.fmf @@ -0,0 +1,2 @@ +plans: + name: /plans/rex-uptime.fmf diff --git a/tests/rex/tmt/plans/rex-uptime.fmf b/tests/rex/tmt/plans/rex-uptime.fmf new file mode 100644 index 000000000..9a72f3cad --- /dev/null +++ b/tests/rex/tmt/plans/rex-uptime.fmf @@ -0,0 +1,49 @@ +name: /plans/rex-uptime +summary: Test Foreman Remote Execution for uptime command + +provision: + how: virtual + image: centos-stream-9 + +discover: + how: fmf + directory: ../../rex-uptime + +execute: + how: tmt + prepare: + - how: shell + name: trigger-and-verify-remote-execution + where: localhost + script: + - | + #!/bin/bash + set -euo pipefail + + echo "Foreman Remote Execution Test from TMT Host" + job_template='Run Command - Script Default' + GUEST_IP=$(tmt --root $(tmt _root) guest --id default-0 | grep 'primary address' | awk '{print $NF}') + echo "TMT Guest IP: ${GUEST_IP}" + + echo "Triggering 'uptime' command on guest IP ${GUEST_IP} via Foreman" + JOB_INFO=$(hammer job-invocation create \ + --job-template "${job_template}" \ + --inputs 'command=uptime' \ + --search-query "facts.ip_address = ${GUEST_IP}" \ + --json) + + JOB_ID=$(echo "${JOB_INFO}" | jq -r '.id') + echo "Foreman Job ID: ${JOB_ID}" + + echo "Waiting for Foreman job ${JOB_ID} to complete" + for i in $(seq 1 120); do + JOB_STATUS=$(hammer job-invocation info --id "${JOB_ID}" --json | jq -r '.state') + echo "Job status: ${JOB_STATUS} (Attempt ${i})" + [[ "$JOB_STATUS" == "finished" ]] && break + [[ "$JOB_STATUS" == "error" || "$JOB_STATUS" == "failed" ]] && exit 1 + sleep 5 + done + + echo "Foreman job ${JOB_ID} completed successfully." + hammer job-invocation info --id "$JOB_ID" + echo "Foreman Remote Execution Test PASSED"