File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load diff This file was deleted.
Load diff This file was deleted.
Load diff This file was deleted.
Load diff This file was deleted.
Original file line number Diff line number Diff line change 1+ summary: Run uptime command check on the provisioned guest
2+ test: ./test.sh
3+ framework: shell
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -euo pipefail
3+
4+ echo " Running uptime check on the TMT guest"
5+ uptime
6+ echo " Uptime test on guest completed successfully."
Original file line number Diff line number Diff line change 1+ plans:
2+ name: /plans/rex-uptime.fmf
Original file line number Diff line number Diff line change 1+ name: /plans/rex-uptime
2+ summary: Test Foreman Remote Execution for uptime command
3+
4+ provision:
5+ how: virtual
6+ image: centos-stream-9
7+
8+ discover:
9+ how: fmf
10+ directory: ../../rex-uptime
11+
12+ execute:
13+ how: tmt
14+ prepare:
15+ - how: shell
16+ name: trigger-and-verify-remote-execution
17+ where: localhost
18+ script:
19+ - |
20+ #!/bin/bash
21+ set -euo pipefail
22+
23+ echo "Foreman Remote Execution Test from TMT Host"
24+ job_template='Run Command - Script Default'
25+ GUEST_IP=$(tmt --root $(tmt _root) guest --id default-0 | grep 'primary address' | awk '{print $NF}')
26+ echo "TMT Guest IP: ${GUEST_IP}"
27+
28+ echo "Triggering 'uptime' command on guest IP ${GUEST_IP} via Foreman"
29+ JOB_INFO=$(hammer job-invocation create \
30+ --job-template "${job_template}" \
31+ --inputs 'command=uptime' \
32+ --search-query "facts.ip_address = ${GUEST_IP}" \
33+ --json)
34+
35+ JOB_ID=$(echo "${JOB_INFO}" | jq -r '.id')
36+ echo "Foreman Job ID: ${JOB_ID}"
37+
38+ echo "Waiting for Foreman job ${JOB_ID} to complete"
39+ for i in $(seq 1 120); do
40+ JOB_STATUS=$(hammer job-invocation info --id "${JOB_ID}" --json | jq -r '.state')
41+ echo "Job status: ${JOB_STATUS} (Attempt ${i})"
42+ [[ "$JOB_STATUS" == "finished" ]] && break
43+ [[ "$JOB_STATUS" == "error" || "$JOB_STATUS" == "failed" ]] && exit 1
44+ sleep 5
45+ done
46+
47+ echo "Foreman job ${JOB_ID} completed successfully."
48+ hammer job-invocation info --id "$JOB_ID"
49+ echo "Foreman Remote Execution Test PASSED"
You can’t perform that action at this time.
0 commit comments