aboutsummaryrefslogtreecommitdiff
path: root/scripts/testing/run-test-baremetal.sh
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-07-25 15:00:44 -0500
committerCraig Jennings <c@cjennings.net>2026-07-25 15:00:44 -0500
commitd52da959bc416e09bc0f3e54994563bd80e19c64 (patch)
treeadaf2ce086e87c548c695e5b4a82eb63f7c926c8 /scripts/testing/run-test-baremetal.sh
parentd25711a61172ffb7b622a6a834ed17fdf52a54de (diff)
downloadarchsetup-d52da959bc416e09bc0f3e54994563bd80e19c64.tar.gz
archsetup-d52da959bc416e09bc0f3e54994563bd80e19c64.zip
refactor(test): share runner and scenario contracts
Diffstat (limited to 'scripts/testing/run-test-baremetal.sh')
-rwxr-xr-xscripts/testing/run-test-baremetal.sh65
1 files changed, 22 insertions, 43 deletions
diff --git a/scripts/testing/run-test-baremetal.sh b/scripts/testing/run-test-baremetal.sh
index d837389..4692fda 100755
--- a/scripts/testing/run-test-baremetal.sh
+++ b/scripts/testing/run-test-baremetal.sh
@@ -23,6 +23,7 @@ source "$SCRIPT_DIR/lib/logging.sh"
source "$SCRIPT_DIR/lib/validation.sh" # live helpers: ssh_cmd, capture_*_state, analyze_log_diff, generate_issue_report
source "$SCRIPT_DIR/lib/vm-utils.sh" # inject_root_key + SSH_OPTS/SSH_KEY_OPT for key auth
source "$SCRIPT_DIR/lib/testinfra.sh" # run_testinfra_validation (authoritative validator)
+source "$SCRIPT_DIR/lib/run-common.sh"
# Parse arguments
ROLLBACK_FIRST=false
@@ -203,30 +204,25 @@ if ! $VALIDATE_ONLY; then
# Start archsetup in background
ssh_cmd "cd /tmp/archsetup-test && nohup bash archsetup > $REMOTE_LOG 2>&1 &"
- success "ArchSetup started in background"
+ sleep 3
+ if archsetup_process_running ssh_cmd; then
+ success "ArchSetup started in background"
+ else
+ fatal "ArchSetup process not found after launch"
+ fi
# Poll for completion
step "Monitoring archsetup progress"
- POLL_COUNT=0
MAX_POLLS=180 # 90 minutes max
- while [ $POLL_COUNT -lt $MAX_POLLS ]; do
- if ssh_cmd "ps aux | grep '[b]ash archsetup' > /dev/null" 2>/dev/null; then
- sleep 30
- POLL_COUNT=$((POLL_COUNT + 1))
- if [ $((POLL_COUNT % 10)) -eq 0 ]; then
- ELAPSED_MINS=$((POLL_COUNT / 2))
- info "Still running... ($ELAPSED_MINS minutes elapsed)"
- # Show last line of progress
- LAST_LINE=$(ssh_cmd "tail -1 $REMOTE_LOG 2>/dev/null" || echo "")
- [ -n "$LAST_LINE" ] && info " $LAST_LINE"
- fi
- else
- break
- fi
- done
+ baremetal_progress() {
+ local last_line
+ info "Still running... ($(("$1" / 2)) minutes elapsed)"
+ last_line=$(ssh_cmd "tail -1 $REMOTE_LOG 2>/dev/null" || echo "")
+ [ -n "$last_line" ] && info " $last_line"
+ }
- if [ $POLL_COUNT -ge $MAX_POLLS ]; then
+ if ! wait_for_archsetup ssh_cmd "$MAX_POLLS" 30 10 baremetal_progress; then
error "ArchSetup timed out after 90 minutes"
ARCHSETUP_COMPLETED=timeout
else
@@ -294,31 +290,14 @@ fi
section "Generating Test Report"
REPORT_FILE="$TEST_RESULTS_DIR/test-report.txt"
-cat > "$REPORT_FILE" << EOFREPORT
-========================================
-Bare Metal ArchSetup Test Report
-========================================
-
-Test ID: $TIMESTAMP
-Date: $(date +'%Y-%m-%d %H:%M:%S')
-Target: $TARGET_HOST
-Test Method: Bare Metal ZFS
-
-Results:
- ArchSetup Completed: $ARCHSETUP_COMPLETED (completion marker, not the installer's exit code)
- Validation: $(if $TEST_PASSED; then echo "PASSED"; else echo "FAILED"; fi)
-
-Validation Summary:
- Passed: $VALIDATION_PASSED
- Failed: $VALIDATION_FAILED
- Warnings: $VALIDATION_WARNINGS
-
-Artifacts:
- Log file: $LOGFILE
- Report: $REPORT_FILE
- Results: $TEST_RESULTS_DIR/
-
-EOFREPORT
+printf -v RUN_REPORT_ARTIFACTS \
+ 'Artifacts:\n Log file: %s\n Report: %s\n Results: %s/' \
+ "$LOGFILE" "$REPORT_FILE" "$TEST_RESULTS_DIR"
+write_archsetup_test_report \
+ "$REPORT_FILE" "Bare Metal ArchSetup Test Report" "$TIMESTAMP" \
+ "Bare Metal ZFS" "Target: $TARGET_HOST" "$ARCHSETUP_COMPLETED" \
+ "$TEST_PASSED" "$VALIDATION_PASSED" "$VALIDATION_FAILED" \
+ "$VALIDATION_WARNINGS" "$RUN_REPORT_ARTIFACTS"
info "Test report saved: $REPORT_FILE"