pii: the GPU tests start pf-serve-vulkan off macOS, so they pass on Linux (#3741)

TestFindJoinsTextsAndMapsBack, TestGPUDeathMovesToCPU,
TestServeStartsWithoutResidencyHeartbeat and TestWarm were red on
ubuntu CI (run 40351272355 at 80857a66c, and earlier). The cause:
cebd0d4c3 made candidates() put a GPU pf-serve first only where there is
one, pf-serve-vulkan or macOS's Metal pf-serve. The tests installed
pf-serve alone and expected it on the GPU ("start pf-serve MTL0"), which
holds on macOS only; on Linux it is the CPU's alone.

gpuInstall installs macOS's pf-serve there and pf-serve-vulkan elsewhere,
and says the GPU's start line; the four tests use it. The code isn't
changed.

Run: go test ./internal/pii/ (ok, macOS). The Linux branch forced on
macOS (gpuInstall's darwin check made false, so pf-serve-vulkan is
installed as on Linux): the four tests pass. GOOS=linux and
GOOS=windows go vet ./internal/pii/ ok.
Not tried: a Linux machine itself (no Docker daemon here); the next CI
run is the check.
This commit is contained in:
yetone
2026-10-27 01:14:22 +08:00
parent 7279bdc28b
commit c84f859dd0
2 changed files with 19 additions and 5 deletions
+14
View File
@@ -8,6 +8,7 @@ import (
"io"
"os"
"path/filepath"
"runtime"
"strings"
"testing"
"time"
@@ -196,6 +197,19 @@ func fakeInstall(t *testing.T, mode string, vulkan bool) string {
return log
}
// gpuInstall is fakeInstall with a GPU's pf-serve to start first:
// macOS's own, which runs on Metal, or elsewhere pf-serve-vulkan, as a
// computer with no Vulkan loader has none (#3741: these tests took
// macOS's for every system, and were red on Linux). It answers the line
// the stand-in logs as it starts there.
func gpuInstall(t *testing.T, mode string) (log, gpuStart string) {
t.Helper()
if runtime.GOOS == "darwin" {
return fakeInstall(t, mode, false), "start pf-serve MTL0"
}
return fakeInstall(t, mode, true), "start pf-serve-vulkan MTL0"
}
// fakeLines are the lines the stand-in logged that start with prefix.
func fakeLines(t *testing.T, log, prefix string) []string {
t.Helper()
+5 -5
View File
@@ -20,7 +20,7 @@ func person(s, e int) redact.Found { return redact.Found{Start: s, End: e, Label
// comes back to each text at that text's own offsets; a text seen before
// isn't asked about again.
func TestFindJoinsTextsAndMapsBack(t *testing.T) {
log := fakeInstall(t, "ok", false)
log, _ := gpuInstall(t, "ok")
texts := []string{"hi Alice", "nothing here", "Bob, Alice and Alice"}
got, err := Find(texts)
if err != nil {
@@ -82,7 +82,7 @@ func TestWithinCutsSpansAtTheTextsEnds(t *testing.T) {
// pf-serve that dies on the GPU is started again on the CPU, which the
// request then gets its answer from, and stays there; the status says why.
func TestGPUDeathMovesToCPU(t *testing.T) {
log := fakeInstall(t, "gpudies", false)
log, gpu := gpuInstall(t, "gpudies")
got, err := Find([]string{"hi Alice"})
if err != nil {
t.Fatal(err)
@@ -90,7 +90,7 @@ func TestGPUDeathMovesToCPU(t *testing.T) {
if !reflect.DeepEqual(got, [][]redact.Found{{person(3, 8)}}) {
t.Fatalf("Find = %v", got)
}
if starts := fakeLines(t, log, "start"); !reflect.DeepEqual(starts, []string{"start pf-serve MTL0", "start pf-serve CPU"}) {
if starts := fakeLines(t, log, "start"); !reflect.DeepEqual(starts, []string{gpu, "start pf-serve CPU"}) {
t.Fatalf("starts = %q", starts)
}
st := Now()
@@ -295,7 +295,7 @@ func TestFailedModelHoldsRequestsBackAtOnce(t *testing.T) {
// woke an idle one ~146 times a second (#3185). The CPU one after a GPU
// death too.
func TestServeStartsWithoutResidencyHeartbeat(t *testing.T) {
log := fakeInstall(t, "gpudies", false)
log, _ := gpuInstall(t, "gpudies")
if _, err := Find([]string{"hi Alice"}); err != nil {
t.Fatal(err)
}
@@ -351,7 +351,7 @@ func TestWarm(t *testing.T) {
Warm()
wait("no failure", func(s Status) bool { return strings.Contains(s.Failed, "can't load noload") })
log := fakeInstall(t, "ok", false)
log, _ := gpuInstall(t, "ok")
srv.failed = "before"
Warm()
wait("not running", func(s Status) bool { return s.Running && s.Device == "MTL0" && s.Failed == "" })