Skip to content

Commit 02bd8f1

Browse files
doringemanclaude
andcommitted
test(e2e): add Linux Docker e2e tests via CI matrix
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Dorin Geman <dorin.geman@docker.com>
1 parent 7e4b3da commit 02bd8f1

4 files changed

Lines changed: 69 additions & 9 deletions

File tree

.github/workflows/e2e-test.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ on:
99

1010
jobs:
1111
e2e-test:
12-
runs-on: macos-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
- os: macos-latest
17+
- os: ubuntu-latest
18+
runs-on: ${{ matrix.os }}
1319
timeout-minutes: 30
1420

1521
steps:
@@ -24,5 +30,9 @@ jobs:
2430
go-version: 1.25.8
2531
cache: true
2632

33+
- name: Set up Docker
34+
if: matrix.os == 'ubuntu-latest'
35+
uses: docker/setup-docker-action@1a6edb0ba9ac496f6850236981f15d8f9a82254d
36+
2737
- name: Run e2e tests
2838
run: make e2e

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ integration-tests:
8686
go test -v -race -count=1 -tags=integration -run "^TestIntegration" -timeout=5m ./cmd/cli/commands
8787
@echo "Integration tests completed!"
8888

89-
e2e: build-llamacpp build
89+
e2e:
9090
@echo "Running e2e tests..."
9191
@echo "Checking test naming conventions..."
9292
@INVALID_TESTS=$$(grep "^func Test" e2e/*_test.go | grep -v "^.*:func TestE2E" | grep -v "^.*:func TestMain"); \

e2e/e2e_test.go

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"os"
2121
"os/exec"
2222
"path/filepath"
23+
"runtime"
2324
"strconv"
2425
"strings"
2526
"testing"
@@ -53,15 +54,27 @@ func run(m *testing.M) int {
5354
fmt.Fprintf(os.Stderr, "e2e: %v\n", err)
5455
return 1
5556
}
57+
cliBin = filepath.Join(root, "cmd", "cli", "model-cli")
58+
59+
if runtime.GOOS == "darwin" {
60+
return runNative(m, root)
61+
}
62+
return runDocker(m, root)
63+
}
5664

57-
fmt.Fprintln(os.Stderr, "e2e: building server and CLI...")
65+
// runNative builds the server from source and runs it as a local process.
66+
func runNative(m *testing.M, root string) int {
67+
fmt.Fprintln(os.Stderr, "e2e: building llama.cpp, server, and CLI...")
68+
if err := makeTarget(root, "build-llamacpp"); err != nil {
69+
fmt.Fprintf(os.Stderr, "e2e: make build-llamacpp failed: %v\n", err)
70+
return 1
71+
}
5872
if err := makeTarget(root, "build"); err != nil {
5973
fmt.Fprintf(os.Stderr, "e2e: make build failed: %v\n", err)
6074
return 1
6175
}
6276

6377
serverBin := filepath.Join(root, "model-runner")
64-
cliBin = filepath.Join(root, "cmd", "cli", "model-cli")
6578
llamaBin := filepath.Join(root, "llamacpp", "install", "bin")
6679

6780
for _, path := range []string{serverBin, cliBin, llamaBin} {
@@ -105,12 +118,42 @@ func run(m *testing.M) int {
105118
_ = server.Wait()
106119
}()
107120

121+
return waitAndRunTests(m)
122+
}
123+
124+
// runDocker builds the Docker image and CLI from source, then lets the CLI
125+
// auto-start the model-runner container on the default Moby port (12434).
126+
func runDocker(m *testing.M, root string) int {
127+
fmt.Fprintln(os.Stderr, "e2e: building Docker image and CLI...")
128+
if err := makeTarget(root, "docker-build"); err != nil {
129+
fmt.Fprintf(os.Stderr, "e2e: make docker-build failed: %v\n", err)
130+
return 1
131+
}
132+
if err := makeTarget(root, "build-cli"); err != nil {
133+
fmt.Fprintf(os.Stderr, "e2e: make build-cli failed: %v\n", err)
134+
return 1
135+
}
136+
137+
fmt.Fprintln(os.Stderr, "e2e: installing runner...")
138+
cmd := exec.Command(cliBin, "install-runner")
139+
cmd.Env = os.Environ()
140+
cmd.Stdout = os.Stderr
141+
cmd.Stderr = os.Stderr
142+
if err := cmd.Run(); err != nil {
143+
fmt.Fprintf(os.Stderr, "e2e: install-runner failed: %v\n", err)
144+
return 1
145+
}
146+
147+
serverURL = "http://localhost:12434"
148+
return waitAndRunTests(m)
149+
}
150+
151+
func waitAndRunTests(m *testing.M) int {
108152
if err := waitForServer(serverURL+"/models", serverStartTimeout); err != nil {
109153
fmt.Fprintf(os.Stderr, "e2e: %v\n", err)
110154
return 1
111155
}
112156
fmt.Fprintf(os.Stderr, "e2e: server ready at %s\n", serverURL)
113-
114157
return m.Run()
115158
}
116159

e2e/inference_test.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,24 @@ import (
77
"net/http"
88
"strings"
99
"testing"
10+
11+
"github.com/docker/model-runner/pkg/inference/platform"
1012
)
1113

1214
type backendTestCase struct {
1315
name string
1416
model string
1517
}
1618

17-
var backends = []backendTestCase{
18-
{"llama.cpp", ggufModel},
19-
{"vllm-metal", mlxModel},
20-
}
19+
var backends = func() []backendTestCase {
20+
b := []backendTestCase{
21+
{"llama.cpp", ggufModel},
22+
}
23+
if platform.SupportsVLLMMetal() {
24+
b = append(b, backendTestCase{"vllm-metal", mlxModel})
25+
}
26+
return b
27+
}()
2128

2229
func TestE2E_Inference(t *testing.T) {
2330
for _, bc := range backends {

0 commit comments

Comments
 (0)