Skip to content

Commit f84e3c7

Browse files
authored
Merge pull request #801 from doringeman/e2e
test(e2e): add ps and unload tests and explicit backend cleanup
2 parents dd9b9d4 + bdb7b04 commit f84e3c7

2 files changed

Lines changed: 43 additions & 2 deletions

File tree

e2e/cli_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,41 @@ func TestE2E_CLI(t *testing.T) {
4040
t.Logf("run output: %s", out)
4141
})
4242

43+
t.Run("PS", func(t *testing.T) {
44+
out, err := runCLI(t, "ps")
45+
if err != nil {
46+
t.Fatalf("cli ps failed: %v\noutput: %s", err, out)
47+
}
48+
// TODO: ps should return lowercased model names like ls does
49+
if !strings.Contains(strings.ToLower(out), "smollm2") {
50+
t.Errorf("expected model in ps output, got:\n%s", out)
51+
}
52+
if !strings.Contains(out, bc.name) {
53+
t.Errorf("expected backend %s in ps output, got:\n%s", bc.name, out)
54+
}
55+
t.Logf("ps output:\n%s", out)
56+
})
57+
58+
t.Run("Unload", func(t *testing.T) {
59+
out, err := runCLI(t, "unload", bc.model)
60+
if err != nil {
61+
t.Fatalf("cli unload failed: %v\noutput: %s", err, out)
62+
}
63+
})
64+
65+
t.Run("PSAfterUnload", func(t *testing.T) {
66+
out, err := runCLI(t, "ps")
67+
if err != nil {
68+
t.Fatalf("cli ps failed: %v\noutput: %s", err, out)
69+
}
70+
if strings.Contains(out, "smollm2") {
71+
t.Errorf("model still running after unload:\n%s", out)
72+
}
73+
if strings.Contains(out, bc.name) {
74+
t.Errorf("backend %s still running after unload:\n%s", bc.name, out)
75+
}
76+
})
77+
4378
t.Run("Remove", func(t *testing.T) {
4479
out, err := runCLI(t, "rm", "-f", bc.model)
4580
if err != nil {

e2e/inference_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"strings"
99
"testing"
1010

11+
"github.com/docker/model-runner/pkg/inference/backends/llamacpp"
12+
"github.com/docker/model-runner/pkg/inference/backends/vllm"
1113
"github.com/docker/model-runner/pkg/inference/platform"
1214
)
1315

@@ -18,10 +20,10 @@ type backendTestCase struct {
1820

1921
var backends = func() []backendTestCase {
2022
b := []backendTestCase{
21-
{"llama.cpp", ggufModel},
23+
{llamacpp.Name, ggufModel},
2224
}
2325
if platform.SupportsVLLMMetal() {
24-
b = append(b, backendTestCase{"vllm-metal", mlxModel})
26+
b = append(b, backendTestCase{vllm.Name, mlxModel})
2527
}
2628
return b
2729
}()
@@ -170,6 +172,10 @@ func TestE2E_Inference(t *testing.T) {
170172
})
171173

172174
t.Run("Remove", func(t *testing.T) {
175+
out, err := runCLI(t, "unload", "--all")
176+
if err != nil {
177+
t.Fatalf("cli unload failed: %v\noutput: %s", err, out)
178+
}
173179
removeModel(t, bc.model)
174180
t.Logf("removed %s", bc.model)
175181
})

0 commit comments

Comments
 (0)