Skip to content

Commit c5ee282

Browse files
committed
Fix Darwin builder timeout guard and e2e build ID handling
1 parent 2b02f28 commit c5ee282

2 files changed

Lines changed: 39 additions & 2 deletions

File tree

integration/builder_cache_darwin_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"runtime"
1010
"strings"
1111
"testing"
12+
"time"
1213

1314
"github.com/kernel/hypeman/cmd/api/config"
1415
"github.com/kernel/hypeman/lib/hypervisor"
@@ -19,6 +20,12 @@ func requireBuilderIntegrationHost(t *testing.T) {
1920
if runtime.GOARCH != "arm64" {
2021
t.Skip("VZ builder integration test requires Apple Silicon")
2122
}
23+
if deadline, ok := t.Deadline(); ok {
24+
const minTimeout = 20 * time.Minute
25+
if time.Until(deadline) < minTimeout {
26+
t.Skipf("builder integration test requires go test timeout >= %s", minTimeout)
27+
}
28+
}
2229
if _, err := exec.LookPath("docker"); err != nil {
2330
t.Skip("builder integration test requires Docker")
2431
}

scripts/e2e-install-test.sh

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,35 @@ error() { echo -e "${RED}[ERROR]${NC} $1"; exit 1; }
2020
pass() { echo -e "${GREEN}[PASS]${NC} $1"; }
2121
fail() { echo -e "${RED}[FAIL]${NC} $1"; exit 1; }
2222

23+
ensure_docker_ready() {
24+
if docker info >/dev/null 2>&1; then
25+
return 0
26+
fi
27+
28+
if [ "$OS" = "darwin" ] && command -v colima >/dev/null 2>&1; then
29+
warn "Docker daemon is not running; starting Colima..."
30+
if colima status >/dev/null 2>&1; then
31+
colima stop --force || true
32+
fi
33+
if ! colima start; then
34+
colima stop --force || true
35+
if ! colima start; then
36+
colima delete --force
37+
colima start
38+
fi
39+
fi
40+
fi
41+
42+
for attempt in $(seq 1 30); do
43+
if docker info >/dev/null 2>&1; then
44+
return 0
45+
fi
46+
sleep 2
47+
done
48+
49+
fail "Docker daemon is required for hypeman build E2E coverage"
50+
}
51+
2352
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
2453
REPO_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
2554
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
@@ -215,6 +244,7 @@ pass "hypeman rm works"
215244
# Build a real image through the installed CLI. This exercises provider wiring,
216245
# the VZ builder VM, guest-to-host registry access, and the resulting image.
217246
E2E_BUILD_VM_NAME="e2e-build-test-vm"
247+
ensure_docker_ready
218248
BUILD_CONTEXT=$(mktemp -d)
219249
BUILD_OUTPUT_FILE=$(mktemp)
220250
trap 'rm -rf "${BUILD_CONTEXT:-}" "${BUILD_OUTPUT_FILE:-}"' EXIT
@@ -226,7 +256,7 @@ EOF
226256

227257
BUILD_OK=false
228258
for i in $(seq 1 30); do
229-
if $HYPEMAN_CMD build --file Dockerfile --timeout 600 \
259+
if $HYPEMAN_CMD --format json --transform id build --file Dockerfile --timeout 600 \
230260
--image-name e2e/build-smoke:latest "$BUILD_CONTEXT" >"$BUILD_OUTPUT_FILE" 2>&1; then
231261
BUILD_OK=true
232262
break
@@ -240,7 +270,7 @@ for i in $(seq 1 30); do
240270
done
241271
[ "$BUILD_OK" = true ] || { cat "$BUILD_OUTPUT_FILE"; fail "hypeman build did not become ready"; }
242272
cat "$BUILD_OUTPUT_FILE"
243-
BUILD_ID=$(sed -n 's/^Build started: //p' "$BUILD_OUTPUT_FILE" | tail -1)
273+
BUILD_ID=$(tr -d '"[:space:]' < "$BUILD_OUTPUT_FILE")
244274
[ -n "$BUILD_ID" ] || fail "hypeman build output did not include a build ID"
245275
BUILD_IMAGE=$($HYPEMAN_CMD --format json --transform image_ref build get "$BUILD_ID") || fail "hypeman build get failed"
246276
BUILD_IMAGE=${BUILD_IMAGE#\"}

0 commit comments

Comments
 (0)