Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions scripts/tests/longhorn-benchmark-delete-guard/native_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,35 @@ import (
)

func TestNativeBenchmarkDeletionGuard(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 4*time.Minute)
defer cancel()
render := exec.CommandContext(ctx, "kubectl", "kustomize", "../../../k8s/providers/hetzner/infrastructure/controllers/longhorn")
// Hosted runners compile the Kubernetes admission dependencies from a cold
// cache. Keep that setup separate from the native proof's execution budget;
// both phases together remain below CI's 20-minute per-package deadline.
buildCtx, cancelBuild := context.WithTimeout(context.Background(), 15*time.Minute)
defer cancelBuild()
render := exec.CommandContext(buildCtx, "kubectl", "kustomize", "../../../k8s/providers/hetzner/infrastructure/controllers/longhorn")
raw, err := render.Output()
if err != nil {
t.Fatal("production Longhorn controller profile could not be rendered")
}
profile := filepath.Join(t.TempDir(), "profile.yaml")
work := t.TempDir()
profile := filepath.Join(work, "profile.yaml")
if err := os.WriteFile(profile, raw, 0600); err != nil {
t.Fatal(err)
}
command := exec.CommandContext(ctx, "go", "test", "-mod=readonly", "-count=1", "-timeout=2m", ".")
command.Dir = "testdata/native-proof"
binary := filepath.Join(work, "native-proof.test")
build := exec.CommandContext(buildCtx, "go", "test", "-c", "-mod=readonly", "-o", binary, ".")
build.Dir = "testdata/native-proof"
build.WaitDelay = 10 * time.Second
if output, err := build.CombinedOutput(); err != nil {
t.Fatalf("native Kubernetes admission proof build failed: %v: %s", err, output)
}
cancelBuild()

ctx, cancel := context.WithTimeout(context.Background(), 4*time.Minute)
defer cancel()
command := exec.CommandContext(ctx, binary, "-test.count=1", "-test.timeout=2m")
command.Dir = build.Dir
command.WaitDelay = 10 * time.Second
command.Env = append(os.Environ(), "LONGHORN_GUARD_RENDER_PATH="+profile)
if output, err := command.CombinedOutput(); err != nil {
t.Fatalf("native Kubernetes admission proof failed: %v: %s", err, output)
Expand Down
Loading