run_amd64_release_matrix.sh 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #!/usr/bin/env bash
  2. # Run the four required installer scenarios in one disposable Debian systemd container.
  3. set -euo pipefail
  4. if [[ $# -ne 3 ]]; then
  5. echo "Usage: $0 NEW_ARCHIVE PREVIOUS_V0.1.1_ARCHIVE OUTPUT_DIR" >&2
  6. exit 2
  7. fi
  8. NEW_ARCHIVE="$(realpath -e -- "$1")"
  9. OLD_ARCHIVE="$(realpath -e -- "$2")"
  10. OUTPUT_DIR="$(realpath -m -- "$3")"
  11. SYSTEMD_IMAGE="${HTH_SYSTEMD_TEST_IMAGE:-localhost/hth-systemd-test:debian13}"
  12. RUN_ID="hth-install-matrix-$(date -u +%Y%m%dT%H%M%SZ)-$$"
  13. CONTAINER="$RUN_ID"
  14. LOG="$OUTPUT_DIR/matrix.log"
  15. RECEIPT="$OUTPUT_DIR/matrix-receipt.txt"
  16. command -v podman >/dev/null 2>&1 || { echo "podman is required" >&2; exit 2; }
  17. podman image exists "$SYSTEMD_IMAGE" || {
  18. echo "missing disposable systemd test image: $SYSTEMD_IMAGE" >&2
  19. exit 2
  20. }
  21. mkdir -p "$OUTPUT_DIR"
  22. : >"$LOG"
  23. cleanup() { podman rm -f "$CONTAINER" >/dev/null 2>&1 || true; }
  24. trap cleanup EXIT
  25. NEW_SHA="$(sha256sum "$NEW_ARCHIVE" | awk '{print $1}')"
  26. OLD_SHA="$(sha256sum "$OLD_ARCHIVE" | awk '{print $1}')"
  27. IMAGE_ID="$(podman image inspect --format '{{.Id}}' "$SYSTEMD_IMAGE")"
  28. podman run -d --name "$CONTAINER" --privileged --systemd=always --tmpfs /run --tmpfs /run/lock -v "$NEW_ARCHIVE:/packages/new.tar.gz:ro" -v "$OLD_ARCHIVE:/packages/old.tar.gz:ro" "$SYSTEMD_IMAGE" /sbin/init >/dev/null
  29. for _ in $(seq 1 100); do
  30. if podman exec "$CONTAINER" systemctl is-system-running >/dev/null 2>&1; then break; fi
  31. sleep 0.1
  32. done
  33. podman exec "$CONTAINER" bash -lc "
  34. set -e
  35. mkdir -p /opt/matrix/new /opt/matrix/old
  36. tar -xzf /packages/new.tar.gz -C /opt/matrix/new
  37. tar -xzf /packages/old.tar.gz -C /opt/matrix/old
  38. chmod +x /opt/matrix/new/*/*.sh /opt/matrix/old/*/*.sh
  39. " 2>&1 | tee -a "$LOG"
  40. run_guest() {
  41. local label="$1" command_text="$2"
  42. echo "${label}_BEGIN" | tee -a "$LOG"
  43. podman exec "$CONTAINER" bash -lc "$command_text" 2>&1 | tee -a "$LOG"
  44. echo "${label}_PASS" | tee -a "$LOG"
  45. }
  46. run_guest SCENARIO_FRESH '
  47. set -e
  48. cd /opt/matrix/new/*
  49. ./install.sh
  50. ./verify-install.sh --no-escalate
  51. '
  52. run_guest SCENARIO_REINSTALL '
  53. set -e
  54. cd /opt/matrix/new/*
  55. ./install.sh
  56. ./verify-install.sh --no-escalate
  57. '
  58. run_guest SCENARIO_PURGE_REINSTALL '
  59. set -e
  60. cd /opt/matrix/new/*
  61. ./uninstall.sh --purge --yes
  62. ./install.sh
  63. ./verify-install.sh --no-escalate
  64. '
  65. run_guest SCENARIO_UPGRADE '
  66. set -e
  67. cd /opt/matrix/new/*
  68. ./uninstall.sh --purge --yes
  69. cd /opt/matrix/old/*
  70. if ./install.sh --backend mock >/tmp/previous-install.log 2>&1; then
  71. previous_direct=PASS
  72. else
  73. previous_direct=KNOWN_PROFILE_PERMISSION_FAILURE
  74. systemctl stop hthd.service >/dev/null 2>&1 || true
  75. chgrp hth /etc/hth/profiles/prod2u-door-temp/profile.json
  76. chmod 0640 /etc/hth/profiles/prod2u-door-temp/profile.json
  77. systemctl start hthd.service
  78. fi
  79. systemctl is-active --quiet hthd.service
  80. /usr/local/bin/hthctl --observe-sock /run/hth/observe/observe.sock --timeout 5s devices >/dev/null
  81. echo "PREVIOUS_RELEASE_RUNNING tag=v0.1.1 commit=7128a205a5cf70256bf6bb3cc87068b1d03e7fd4 direct_install=$previous_direct"
  82. cd /opt/matrix/new/*
  83. ./install.sh --upgrade
  84. ./verify-install.sh --no-escalate
  85. '
  86. run_guest SCENARIO_UPGRADE_FROM_FAILED_OLD '
  87. set -e
  88. cd /opt/matrix/new/*
  89. ./uninstall.sh --purge --yes
  90. cd /opt/matrix/old/*
  91. if ./install.sh --backend mock >/tmp/previous-failed-install.log 2>&1; then
  92. echo "expected v0.1.1 permission failure was not reproduced" >&2
  93. exit 1
  94. fi
  95. grep -q "Job for hthd.service failed" /tmp/previous-failed-install.log
  96. cd /opt/matrix/new/*
  97. ./install.sh --upgrade
  98. ./verify-install.sh --no-escalate
  99. '
  100. {
  101. echo "schema=hth-install-matrix-receipt-v1"
  102. echo "status=PASS"
  103. echo "run_id=$RUN_ID"
  104. echo "systemd_image=$SYSTEMD_IMAGE"
  105. echo "systemd_image_id=$IMAGE_ID"
  106. echo "new_archive=$NEW_ARCHIVE"
  107. echo "new_archive_sha256=$NEW_SHA"
  108. echo "previous_release_tag=v0.1.1"
  109. echo "previous_release_commit=7128a205a5cf70256bf6bb3cc87068b1d03e7fd4"
  110. echo "previous_archive=$OLD_ARCHIVE"
  111. echo "previous_archive_sha256=$OLD_SHA"
  112. echo "fresh_install=PASS"
  113. echo "same_version_reinstall=PASS"
  114. echo "purge_reinstall=PASS"
  115. echo "previous_release_upgrade=PASS"
  116. echo "upgrade_from_failed_previous_install=PASS"
  117. echo "hardware_validation=NOT RUN"
  118. echo "com_validation=NOT RUN"
  119. echo "jtag_validation=NOT RUN"
  120. echo "real_thermal_performance=NOT RUN"
  121. echo "generated_at_utc=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
  122. echo "log_sha256=$(sha256sum "$LOG" | awk '{print $1}')"
  123. } >"$RECEIPT"
  124. cat "$RECEIPT"
  125. echo "HTH_INSTALL_MATRIX_PASS"