Skip to content

Commit 9a87bd5

Browse files
authored
chore: stabilize testing (#132)
* Stabilize linux test network subnet allocation * Add subnet lease allocator for tests * tests: prewarm ci cache and mirror images via local registry * tests: prewarm hypervisor binaries to avoid extraction races * vmm: lock and atomically install extracted cloud-hypervisor binaries * tests: require prewarmed system binaries only on linux * ci: consecutive stability check 2 of 5 * ci: consecutive stability check 3 of 5 * ci: consecutive stability check 4 of 5 * ci: consecutive stability check 5 of 5
1 parent b7a4031 commit 9a87bd5

20 files changed

Lines changed: 1183 additions & 79 deletions

.github/workflows/test.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ jobs:
6565
- name: Build
6666
run: make build
6767

68+
- name: Prewarm test cache
69+
env:
70+
HYPEMAN_TEST_REGISTRY: 127.0.0.1:5001
71+
run: |
72+
export HYPEMAN_TEST_PREWARM_DIR="$HOME/.cache/hypeman-ci/linux-amd64"
73+
go run ./cmd/test-prewarm
74+
6875
- name: Check gofmt
6976
run: |
7077
set -euo pipefail
@@ -91,7 +98,11 @@ jobs:
9198
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
9299
TLS_TEST_DOMAIN: "test.hypeman-development.com"
93100
TLS_ALLOWED_DOMAINS: '*.hypeman-development.com'
94-
run: make test TEST_TIMEOUT=20m
101+
HYPEMAN_TEST_PREWARM_STRICT: "1"
102+
HYPEMAN_TEST_REGISTRY: 127.0.0.1:5001
103+
run: |
104+
export HYPEMAN_TEST_PREWARM_DIR="$HOME/.cache/hypeman-ci/linux-amd64"
105+
make test TEST_TIMEOUT=20m
95106
96107
test-darwin:
97108
runs-on: [self-hosted, macos, arm64]
@@ -123,6 +134,13 @@ jobs:
123134
- name: Build
124135
run: make build
125136

137+
- name: Prewarm test cache
138+
env:
139+
HYPEMAN_TEST_REGISTRY: 127.0.0.1:5001
140+
run: |
141+
export HYPEMAN_TEST_PREWARM_DIR="$HOME/.cache/hypeman-ci/darwin-arm64"
142+
go run ./cmd/test-prewarm
143+
126144
- name: Check gofmt
127145
run: |
128146
set -euo pipefail
@@ -142,7 +160,11 @@ jobs:
142160
GO_TEST_TIMEOUT: 600s
143161
DEFAULT_HYPERVISOR: vz
144162
JWT_SECRET: ci-test-secret
145-
run: make test
163+
HYPEMAN_TEST_PREWARM_STRICT: "1"
164+
HYPEMAN_TEST_REGISTRY: 127.0.0.1:5001
165+
run: |
166+
export HYPEMAN_TEST_PREWARM_DIR="$HOME/.cache/hypeman-ci/darwin-arm64"
167+
make test
146168
- name: Cleanup
147169
if: always()
148170
run: |

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,17 @@ test-linux: ensure-ch-binaries ensure-firecracker-binaries ensure-caddy-binaries
269269
if [ -n "$(VERBOSE)" ]; then VERBOSE_FLAG="-v"; fi; \
270270
if [ -n "$(TEST)" ]; then \
271271
echo "Running specific test: $(TEST)"; \
272-
sudo env "PATH=$$TEST_PATH" "DOCKER_CONFIG=$${DOCKER_CONFIG:-$$HOME/.docker}" go test -tags containers_image_openpgp -run=$(TEST) $$VERBOSE_FLAG -timeout=$(TEST_TIMEOUT) ./...; \
272+
sudo env "PATH=$$TEST_PATH" "DOCKER_CONFIG=$${DOCKER_CONFIG:-$$HOME/.docker}" \
273+
"HYPEMAN_TEST_PREWARM_DIR=$${HYPEMAN_TEST_PREWARM_DIR:-}" \
274+
"HYPEMAN_TEST_PREWARM_STRICT=$${HYPEMAN_TEST_PREWARM_STRICT:-}" \
275+
"HYPEMAN_TEST_REGISTRY=$${HYPEMAN_TEST_REGISTRY:-}" \
276+
go test -tags containers_image_openpgp -run=$(TEST) $$VERBOSE_FLAG -timeout=$(TEST_TIMEOUT) ./...; \
273277
else \
274-
sudo env "PATH=$$TEST_PATH" "DOCKER_CONFIG=$${DOCKER_CONFIG:-$$HOME/.docker}" go test -tags containers_image_openpgp $$VERBOSE_FLAG -timeout=$(TEST_TIMEOUT) ./...; \
278+
sudo env "PATH=$$TEST_PATH" "DOCKER_CONFIG=$${DOCKER_CONFIG:-$$HOME/.docker}" \
279+
"HYPEMAN_TEST_PREWARM_DIR=$${HYPEMAN_TEST_PREWARM_DIR:-}" \
280+
"HYPEMAN_TEST_PREWARM_STRICT=$${HYPEMAN_TEST_PREWARM_STRICT:-}" \
281+
"HYPEMAN_TEST_REGISTRY=$${HYPEMAN_TEST_REGISTRY:-}" \
282+
go test -tags containers_image_openpgp $$VERBOSE_FLAG -timeout=$(TEST_TIMEOUT) ./...; \
275283
fi
276284

277285
# macOS tests (no sudo needed, adds e2fsprogs to PATH)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//go:build linux
2+
3+
package main
4+
5+
import (
6+
"fmt"
7+
8+
"github.com/kernel/hypeman/lib/hypervisor/firecracker"
9+
"github.com/kernel/hypeman/lib/paths"
10+
"github.com/kernel/hypeman/lib/vmm"
11+
)
12+
13+
func ensureHypervisorBinaries(p *paths.Paths) (int, string, error) {
14+
chBinaries := 0
15+
for _, version := range vmm.SupportedVersions {
16+
if _, err := vmm.GetBinaryPath(p, version); err != nil {
17+
return 0, "", fmt.Errorf("cloud-hypervisor %s: %w", version, err)
18+
}
19+
chBinaries++
20+
}
21+
22+
fcPath, err := firecracker.NewStarter().GetBinaryPath(p, "")
23+
if err != nil {
24+
return 0, "", fmt.Errorf("firecracker: %w", err)
25+
}
26+
27+
return chBinaries, fcPath, nil
28+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//go:build !linux
2+
3+
package main
4+
5+
import "github.com/kernel/hypeman/lib/paths"
6+
7+
func ensureHypervisorBinaries(_ *paths.Paths) (int, string, error) {
8+
return 0, "", nil
9+
}

0 commit comments

Comments
 (0)