lint: enable usetesting, disable tenv (#10594)

This commit is contained in:
Michael Yang 2025-05-08 11:42:14 -07:00 committed by GitHub
parent b585a58121
commit 6e9a7a2568
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 55 additions and 87 deletions

View file

@ -19,8 +19,8 @@ linters:
- nolintlint - nolintlint
- nosprintfhostport - nosprintfhostport
- staticcheck - staticcheck
- tenv
- unconvert - unconvert
- usetesting
- wastedassign - wastedassign
- whitespace - whitespace
disable: disable:

View file

@ -1,7 +1,6 @@
package api package api
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http" "net/http"
@ -137,7 +136,7 @@ func TestClientStream(t *testing.T) {
client := NewClient(&url.URL{Scheme: "http", Host: ts.Listener.Addr().String()}, http.DefaultClient) client := NewClient(&url.URL{Scheme: "http", Host: ts.Listener.Addr().String()}, http.DefaultClient)
var receivedChunks []ChatResponse var receivedChunks []ChatResponse
err := client.stream(context.Background(), http.MethodPost, "/v1/chat", nil, func(chunk []byte) error { err := client.stream(t.Context(), http.MethodPost, "/v1/chat", nil, func(chunk []byte) error {
var resp ChatResponse var resp ChatResponse
if err := json.Unmarshal(chunk, &resp); err != nil { if err := json.Unmarshal(chunk, &resp); err != nil {
return fmt.Errorf("failed to unmarshal chunk: %w", err) return fmt.Errorf("failed to unmarshal chunk: %w", err)
@ -223,7 +222,7 @@ func TestClientDo(t *testing.T) {
ID string `json:"id"` ID string `json:"id"`
Success bool `json:"success"` Success bool `json:"success"`
} }
err := client.do(context.Background(), http.MethodPost, "/v1/messages", nil, &resp) err := client.do(t.Context(), http.MethodPost, "/v1/messages", nil, &resp)
if tc.wantErr != "" { if tc.wantErr != "" {
if err == nil { if err == nil {

View file

@ -78,7 +78,7 @@ func BenchmarkColdStart(b *testing.B) {
for _, tt := range tests { for _, tt := range tests {
b.Run(fmt.Sprintf("%s/cold/%s", m, tt.name), func(b *testing.B) { b.Run(fmt.Sprintf("%s/cold/%s", m, tt.name), func(b *testing.B) {
ctx := context.Background() ctx := b.Context()
// Set number of tokens as our throughput metric // Set number of tokens as our throughput metric
b.SetBytes(int64(tt.maxTokens)) b.SetBytes(int64(tt.maxTokens))
@ -113,7 +113,7 @@ func BenchmarkWarmStart(b *testing.B) {
for _, tt := range tests { for _, tt := range tests {
b.Run(fmt.Sprintf("%s/warm/%s", m, tt.name), func(b *testing.B) { b.Run(fmt.Sprintf("%s/warm/%s", m, tt.name), func(b *testing.B) {
ctx := context.Background() ctx := b.Context()
// Pre-warm the model // Pre-warm the model
warmup(client, m, tt.prompt, b) warmup(client, m, tt.prompt, b)
@ -140,7 +140,7 @@ func setup(b *testing.B) *api.Client {
if err != nil { if err != nil {
b.Fatal(err) b.Fatal(err)
} }
if _, err := client.Show(context.Background(), &api.ShowRequest{Model: modelName(b)}); err != nil { if _, err := client.Show(b.Context(), &api.ShowRequest{Model: modelName(b)}); err != nil {
b.Fatalf("Model unavailable: %v", err) b.Fatalf("Model unavailable: %v", err)
} }

View file

@ -2,7 +2,6 @@ package cmd
import ( import (
"bytes" "bytes"
"context"
"encoding/json" "encoding/json"
"io" "io"
"net/http" "net/http"
@ -337,7 +336,7 @@ func TestDeleteHandler(t *testing.T) {
t.Cleanup(mockServer.Close) t.Cleanup(mockServer.Close)
cmd := &cobra.Command{} cmd := &cobra.Command{}
cmd.SetContext(context.TODO()) cmd.SetContext(t.Context())
if err := DeleteHandler(cmd, []string{"test-model"}); err != nil { if err := DeleteHandler(cmd, []string{"test-model"}); err != nil {
t.Fatalf("DeleteHandler failed: %v", err) t.Fatalf("DeleteHandler failed: %v", err)
} }
@ -399,11 +398,6 @@ func TestGetModelfileName(t *testing.T) {
var expectedFilename string var expectedFilename string
if tt.fileExists { if tt.fileExists {
tempDir, err := os.MkdirTemp("", "modelfiledir")
defer os.RemoveAll(tempDir)
if err != nil {
t.Fatalf("temp modelfile dir creation failed: %v", err)
}
var fn string var fn string
if tt.modelfileName != "" { if tt.modelfileName != "" {
fn = tt.modelfileName fn = tt.modelfileName
@ -411,7 +405,7 @@ func TestGetModelfileName(t *testing.T) {
fn = "Modelfile" fn = "Modelfile"
} }
tempFile, err := os.CreateTemp(tempDir, fn) tempFile, err := os.CreateTemp(t.TempDir(), fn)
if err != nil { if err != nil {
t.Fatalf("temp modelfile creation failed: %v", err) t.Fatalf("temp modelfile creation failed: %v", err)
} }
@ -530,7 +524,7 @@ func TestPushHandler(t *testing.T) {
cmd := &cobra.Command{} cmd := &cobra.Command{}
cmd.Flags().Bool("insecure", false, "") cmd.Flags().Bool("insecure", false, "")
cmd.SetContext(context.TODO()) cmd.SetContext(t.Context())
// Redirect stderr to capture progress output // Redirect stderr to capture progress output
oldStderr := os.Stderr oldStderr := os.Stderr
@ -635,7 +629,7 @@ func TestListHandler(t *testing.T) {
t.Setenv("OLLAMA_HOST", mockServer.URL) t.Setenv("OLLAMA_HOST", mockServer.URL)
cmd := &cobra.Command{} cmd := &cobra.Command{}
cmd.SetContext(context.TODO()) cmd.SetContext(t.Context())
// Capture stdout // Capture stdout
oldStdout := os.Stdout oldStdout := os.Stdout
@ -730,7 +724,7 @@ func TestCreateHandler(t *testing.T) {
})) }))
t.Setenv("OLLAMA_HOST", mockServer.URL) t.Setenv("OLLAMA_HOST", mockServer.URL)
t.Cleanup(mockServer.Close) t.Cleanup(mockServer.Close)
tempFile, err := os.CreateTemp("", "modelfile") tempFile, err := os.CreateTemp(t.TempDir(), "modelfile")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -750,7 +744,7 @@ func TestCreateHandler(t *testing.T) {
} }
cmd.Flags().Bool("insecure", false, "") cmd.Flags().Bool("insecure", false, "")
cmd.SetContext(context.TODO()) cmd.SetContext(t.Context())
// Redirect stderr to capture progress output // Redirect stderr to capture progress output
oldStderr := os.Stderr oldStderr := os.Stderr

View file

@ -16,7 +16,7 @@ func TestLLMServerCompletionFormat(t *testing.T) {
// of a mess, and but it's good enough, until we can refactoring the // of a mess, and but it's good enough, until we can refactoring the
// Completion method to be more testable. // Completion method to be more testable.
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(t.Context())
s := &llmServer{ s := &llmServer{
sem: semaphore.NewWeighted(1), // required to prevent nil panic sem: semaphore.NewWeighted(1), // required to prevent nil panic
} }

View file

@ -3,6 +3,7 @@ package server
import ( import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
"errors"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -91,11 +92,7 @@ func createMockGGUFData(architecture string, vision bool) []byte {
func TestModelCapabilities(t *testing.T) { func TestModelCapabilities(t *testing.T) {
// Create a temporary directory for test files // Create a temporary directory for test files
tempDir, err := os.MkdirTemp("", "model_capabilities_test") tempDir := t.TempDir()
if err != nil {
t.Fatalf("Failed to create temp directory: %v", err)
}
defer os.RemoveAll(tempDir)
// Create different types of mock model files // Create different types of mock model files
completionModelPath := filepath.Join(tempDir, "model.bin") completionModelPath := filepath.Join(tempDir, "model.bin")
@ -104,21 +101,13 @@ func TestModelCapabilities(t *testing.T) {
// Create a simple model file for tests that don't depend on GGUF content // Create a simple model file for tests that don't depend on GGUF content
simpleModelPath := filepath.Join(tempDir, "simple_model.bin") simpleModelPath := filepath.Join(tempDir, "simple_model.bin")
err = os.WriteFile(completionModelPath, createMockGGUFData("llama", false), 0o644) if err := errors.Join(
if err != nil { os.WriteFile(completionModelPath, createMockGGUFData("llama", false), 0o644),
t.Fatalf("Failed to create completion model file: %v", err) os.WriteFile(visionModelPath, createMockGGUFData("llama", true), 0o644),
} os.WriteFile(embeddingModelPath, createMockGGUFData("bert", false), 0o644),
err = os.WriteFile(visionModelPath, createMockGGUFData("llama", true), 0o644) os.WriteFile(simpleModelPath, []byte("dummy model data"), 0o644),
if err != nil { ); err != nil {
t.Fatalf("Failed to create completion model file: %v", err) t.Fatalf("Failed to create model files: %v", err)
}
err = os.WriteFile(embeddingModelPath, createMockGGUFData("bert", false), 0o644)
if err != nil {
t.Fatalf("Failed to create embedding model file: %v", err)
}
err = os.WriteFile(simpleModelPath, []byte("dummy model data"), 0o644)
if err != nil {
t.Fatalf("Failed to create simple model file: %v", err)
} }
toolsInsertTemplate, err := template.Parse("{{ .prompt }}{{ if .tools }}{{ .tools }}{{ end }}{{ if .suffix }}{{ .suffix }}{{ end }}") toolsInsertTemplate, err := template.Parse("{{ .prompt }}{{ if .tools }}{{ .tools }}{{ end }}{{ if .suffix }}{{ .suffix }}{{ end }}")
@ -236,27 +225,18 @@ func TestModelCapabilities(t *testing.T) {
func TestModelCheckCapabilities(t *testing.T) { func TestModelCheckCapabilities(t *testing.T) {
// Create a temporary directory for test files // Create a temporary directory for test files
tempDir, err := os.MkdirTemp("", "model_check_capabilities_test") tempDir := t.TempDir()
if err != nil {
t.Fatalf("Failed to create temp directory: %v", err)
}
defer os.RemoveAll(tempDir)
visionModelPath := filepath.Join(tempDir, "vision_model.bin") visionModelPath := filepath.Join(tempDir, "vision_model.bin")
simpleModelPath := filepath.Join(tempDir, "model.bin") simpleModelPath := filepath.Join(tempDir, "model.bin")
embeddingModelPath := filepath.Join(tempDir, "embedding_model.bin") embeddingModelPath := filepath.Join(tempDir, "embedding_model.bin")
err = os.WriteFile(simpleModelPath, []byte("dummy model data"), 0o644) if err := errors.Join(
if err != nil { os.WriteFile(simpleModelPath, []byte("dummy model data"), 0o644),
t.Fatalf("Failed to create simple model file: %v", err) os.WriteFile(visionModelPath, createMockGGUFData("llama", true), 0o644),
} os.WriteFile(embeddingModelPath, createMockGGUFData("bert", false), 0o644),
err = os.WriteFile(visionModelPath, createMockGGUFData("llama", true), 0o644) ); err != nil {
if err != nil { t.Fatalf("Failed to create model files: %v", err)
t.Fatalf("Failed to create vision model file: %v", err)
}
err = os.WriteFile(embeddingModelPath, createMockGGUFData("bert", false), 0o644)
if err != nil {
t.Fatalf("Failed to create embedding model file: %v", err)
} }
toolsInsertTemplate, err := template.Parse("{{ .prompt }}{{ if .tools }}{{ .tools }}{{ end }}{{ if .suffix }}{{ .suffix }}{{ end }}") toolsInsertTemplate, err := template.Parse("{{ .prompt }}{{ if .tools }}{{ .tools }}{{ end }}{{ if .suffix }}{{ .suffix }}{{ end }}")

View file

@ -3,7 +3,6 @@
package backoff package backoff
import ( import (
"context"
"testing" "testing"
"testing/synctest" "testing/synctest"
"time" "time"
@ -29,7 +28,7 @@ func TestLoopAllocs(t *testing.T) {
} }
func BenchmarkLoop(b *testing.B) { func BenchmarkLoop(b *testing.B) {
ctx := context.Background() ctx := b.Context()
synctest.Run(func() { synctest.Run(func() {
for n := range Loop(ctx, 100*time.Millisecond) { for n := range Loop(ctx, 100*time.Millisecond) {
if n == b.N { if n == b.N {

View file

@ -1,7 +1,6 @@
package server package server
import ( import (
"os"
"path/filepath" "path/filepath"
"testing" "testing"
@ -11,9 +10,7 @@ import (
func TestGetBlobsPath(t *testing.T) { func TestGetBlobsPath(t *testing.T) {
// GetBlobsPath expects an actual directory to exist // GetBlobsPath expects an actual directory to exist
dir, err := os.MkdirTemp("", "ollama-test") tempDir := t.TempDir()
require.NoError(t, err)
defer os.RemoveAll(dir)
tests := []struct { tests := []struct {
name string name string
@ -24,19 +21,19 @@ func TestGetBlobsPath(t *testing.T) {
{ {
"empty digest", "empty digest",
"", "",
filepath.Join(dir, "blobs"), filepath.Join(tempDir, "blobs"),
nil, nil,
}, },
{ {
"valid with colon", "valid with colon",
"sha256:456402914e838a953e0cf80caa6adbe75383d9e63584a964f504a7bbb8f7aad9", "sha256:456402914e838a953e0cf80caa6adbe75383d9e63584a964f504a7bbb8f7aad9",
filepath.Join(dir, "blobs", "sha256-456402914e838a953e0cf80caa6adbe75383d9e63584a964f504a7bbb8f7aad9"), filepath.Join(tempDir, "blobs", "sha256-456402914e838a953e0cf80caa6adbe75383d9e63584a964f504a7bbb8f7aad9"),
nil, nil,
}, },
{ {
"valid with dash", "valid with dash",
"sha256-456402914e838a953e0cf80caa6adbe75383d9e63584a964f504a7bbb8f7aad9", "sha256-456402914e838a953e0cf80caa6adbe75383d9e63584a964f504a7bbb8f7aad9",
filepath.Join(dir, "blobs", "sha256-456402914e838a953e0cf80caa6adbe75383d9e63584a964f504a7bbb8f7aad9"), filepath.Join(tempDir, "blobs", "sha256-456402914e838a953e0cf80caa6adbe75383d9e63584a964f504a7bbb8f7aad9"),
nil, nil,
}, },
{ {
@ -60,7 +57,7 @@ func TestGetBlobsPath(t *testing.T) {
} }
for _, tc := range tests { for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Setenv("OLLAMA_MODELS", dir) t.Setenv("OLLAMA_MODELS", tempDir)
got, err := GetBlobsPath(tc.digest) got, err := GetBlobsPath(tc.digest)

View file

@ -2,7 +2,6 @@ package server
import ( import (
"bytes" "bytes"
"context"
"image" "image"
"image/png" "image/png"
"testing" "testing"
@ -318,7 +317,7 @@ func TestChatPrompt(t *testing.T) {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
model := tt.model model := tt.model
opts := api.Options{Runner: api.Runner{NumCtx: tt.limit}} opts := api.Options{Runner: api.Runner{NumCtx: tt.limit}}
prompt, images, err := chatPrompt(context.TODO(), &model, mockRunner{}.Tokenize, &opts, tt.msgs, nil) prompt, images, err := chatPrompt(t.Context(), &model, mockRunner{}.Tokenize, &opts, tt.msgs, nil)
if tt.error == nil && err != nil { if tt.error == nil && err != nil {
t.Fatal(err) t.Fatal(err)
} else if tt.error != nil && err != tt.error { } else if tt.error != nil && err != tt.error {

View file

@ -87,7 +87,7 @@ func TestGenerateChat(t *testing.T) {
}, },
} }
go s.sched.Run(context.TODO()) go s.sched.Run(t.Context())
_, digest := createBinFile(t, ggml.KV{ _, digest := createBinFile(t, ggml.KV{
"general.architecture": "llama", "general.architecture": "llama",
@ -631,7 +631,7 @@ func TestGenerate(t *testing.T) {
}, },
} }
go s.sched.Run(context.TODO()) go s.sched.Run(t.Context())
_, digest := createBinFile(t, ggml.KV{ _, digest := createBinFile(t, ggml.KV{
"general.architecture": "llama", "general.architecture": "llama",

View file

@ -527,7 +527,7 @@ func TestRoutes(t *testing.T) {
for _, tc := range testCases { for _, tc := range testCases {
t.Run(tc.Name, func(t *testing.T) { t.Run(tc.Name, func(t *testing.T) {
u := httpSrv.URL + tc.Path u := httpSrv.URL + tc.Path
req, err := http.NewRequestWithContext(context.TODO(), tc.Method, u, nil) req, err := http.NewRequestWithContext(t.Context(), tc.Method, u, nil)
if err != nil { if err != nil {
t.Fatalf("failed to create request: %v", err) t.Fatalf("failed to create request: %v", err)
} }

View file

@ -26,7 +26,7 @@ func TestMain(m *testing.M) {
} }
func TestInitScheduler(t *testing.T) { func TestInitScheduler(t *testing.T) {
ctx, done := context.WithCancel(context.Background()) ctx, done := context.WithCancel(t.Context())
defer done() defer done()
s := InitScheduler(ctx) s := InitScheduler(ctx)
s.loadedMu.Lock() s.loadedMu.Lock()
@ -35,7 +35,7 @@ func TestInitScheduler(t *testing.T) {
} }
func TestLoad(t *testing.T) { func TestLoad(t *testing.T) {
ctx, done := context.WithTimeout(context.Background(), 20*time.Millisecond) ctx, done := context.WithTimeout(t.Context(), 20*time.Millisecond)
defer done() defer done()
s := InitScheduler(ctx) s := InitScheduler(ctx)
var f *ggml.GGML // value not used in tests var f *ggml.GGML // value not used in tests
@ -167,7 +167,7 @@ func getCpuFn() discover.GpuInfoList {
} }
func TestRequestsSameModelSameRequest(t *testing.T) { func TestRequestsSameModelSameRequest(t *testing.T) {
ctx, done := context.WithTimeout(context.Background(), 500*time.Millisecond) ctx, done := context.WithTimeout(t.Context(), 500*time.Millisecond)
defer done() defer done()
s := InitScheduler(ctx) s := InitScheduler(ctx)
s.getGpuFn = getGpuFn s.getGpuFn = getGpuFn
@ -210,7 +210,7 @@ func TestRequestsSameModelSameRequest(t *testing.T) {
} }
func TestRequestsSimpleReloadSameModel(t *testing.T) { func TestRequestsSimpleReloadSameModel(t *testing.T) {
ctx, done := context.WithTimeout(context.Background(), 500*time.Millisecond) ctx, done := context.WithTimeout(t.Context(), 500*time.Millisecond)
defer done() defer done()
s := InitScheduler(ctx) s := InitScheduler(ctx)
s.getGpuFn = getGpuFn s.getGpuFn = getGpuFn
@ -258,7 +258,7 @@ func TestRequestsSimpleReloadSameModel(t *testing.T) {
} }
func TestRequestsMultipleLoadedModels(t *testing.T) { func TestRequestsMultipleLoadedModels(t *testing.T) {
ctx, done := context.WithTimeout(context.Background(), 500*time.Millisecond) ctx, done := context.WithTimeout(t.Context(), 500*time.Millisecond)
defer done() defer done()
s := InitScheduler(ctx) s := InitScheduler(ctx)
s.getGpuFn = getGpuFn s.getGpuFn = getGpuFn
@ -355,7 +355,7 @@ func TestRequestsMultipleLoadedModels(t *testing.T) {
} }
func TestGetRunner(t *testing.T) { func TestGetRunner(t *testing.T) {
ctx, done := context.WithTimeout(context.Background(), 3*time.Second) ctx, done := context.WithTimeout(t.Context(), 3*time.Second)
defer done() defer done()
a := newScenarioRequest(t, ctx, "ollama-model-1a", 10, &api.Duration{Duration: 2 * time.Millisecond}) a := newScenarioRequest(t, ctx, "ollama-model-1a", 10, &api.Duration{Duration: 2 * time.Millisecond})
@ -408,7 +408,7 @@ func TestGetRunner(t *testing.T) {
} }
func TestExpireRunner(t *testing.T) { func TestExpireRunner(t *testing.T) {
ctx, done := context.WithTimeout(context.Background(), 20*time.Millisecond) ctx, done := context.WithTimeout(t.Context(), 20*time.Millisecond)
defer done() defer done()
s := InitScheduler(ctx) s := InitScheduler(ctx)
req := &LlmRequest{ req := &LlmRequest{
@ -455,7 +455,7 @@ func TestExpireRunner(t *testing.T) {
// TODO - add one scenario that triggers the bogus finished event with positive ref count // TODO - add one scenario that triggers the bogus finished event with positive ref count
func TestPrematureExpired(t *testing.T) { func TestPrematureExpired(t *testing.T) {
ctx, done := context.WithTimeout(context.Background(), 500*time.Millisecond) ctx, done := context.WithTimeout(t.Context(), 500*time.Millisecond)
defer done() defer done()
// Same model, same request // Same model, same request
@ -502,7 +502,7 @@ func TestPrematureExpired(t *testing.T) {
} }
func TestUseLoadedRunner(t *testing.T) { func TestUseLoadedRunner(t *testing.T) {
ctx, done := context.WithTimeout(context.Background(), 100*time.Millisecond) ctx, done := context.WithTimeout(t.Context(), 100*time.Millisecond)
req := &LlmRequest{ req := &LlmRequest{
ctx: ctx, ctx: ctx,
opts: api.DefaultOptions(), opts: api.DefaultOptions(),
@ -529,7 +529,7 @@ func TestUseLoadedRunner(t *testing.T) {
} }
func TestUpdateFreeSpace(t *testing.T) { func TestUpdateFreeSpace(t *testing.T) {
ctx, done := context.WithTimeout(context.Background(), 100*time.Millisecond) ctx, done := context.WithTimeout(t.Context(), 100*time.Millisecond)
defer done() defer done()
gpus := discover.GpuInfoList{ gpus := discover.GpuInfoList{
{ {
@ -562,7 +562,7 @@ func TestUpdateFreeSpace(t *testing.T) {
} }
func TestFilterGPUsWithoutLoadingModels(t *testing.T) { func TestFilterGPUsWithoutLoadingModels(t *testing.T) {
ctx, done := context.WithTimeout(context.Background(), 100*time.Millisecond) ctx, done := context.WithTimeout(t.Context(), 100*time.Millisecond)
defer done() defer done()
gpus := discover.GpuInfoList{ gpus := discover.GpuInfoList{
{ {
@ -596,7 +596,7 @@ func TestFilterGPUsWithoutLoadingModels(t *testing.T) {
} }
func TestFindRunnerToUnload(t *testing.T) { func TestFindRunnerToUnload(t *testing.T) {
ctx, done := context.WithTimeout(context.Background(), 100*time.Millisecond) ctx, done := context.WithTimeout(t.Context(), 100*time.Millisecond)
defer done() defer done()
r1 := &runnerRef{refCount: 1, sessionDuration: 1, numParallel: 1} r1 := &runnerRef{refCount: 1, sessionDuration: 1, numParallel: 1}
@ -616,7 +616,7 @@ func TestFindRunnerToUnload(t *testing.T) {
} }
func TestNeedsReload(t *testing.T) { func TestNeedsReload(t *testing.T) {
ctx, done := context.WithTimeout(context.Background(), 100*time.Millisecond) ctx, done := context.WithTimeout(t.Context(), 100*time.Millisecond)
defer done() defer done()
llm := &mockLlm{estimatedVRAMByGPU: map[string]uint64{}} llm := &mockLlm{estimatedVRAMByGPU: map[string]uint64{}}
@ -663,7 +663,7 @@ func TestNeedsReload(t *testing.T) {
} }
func TestUnloadAllRunners(t *testing.T) { func TestUnloadAllRunners(t *testing.T) {
ctx, done := context.WithTimeout(context.Background(), 100*time.Millisecond) ctx, done := context.WithTimeout(t.Context(), 100*time.Millisecond)
defer done() defer done()
llm1 := &mockLlm{estimatedVRAMByGPU: map[string]uint64{}} llm1 := &mockLlm{estimatedVRAMByGPU: map[string]uint64{}}
@ -695,7 +695,7 @@ func TestUnload(t *testing.T) {
} }
func TestAlreadyCanceled(t *testing.T) { func TestAlreadyCanceled(t *testing.T) {
ctx, done := context.WithTimeout(context.Background(), 500*time.Millisecond) ctx, done := context.WithTimeout(t.Context(), 500*time.Millisecond)
defer done() defer done()
dctx, done2 := context.WithCancel(ctx) dctx, done2 := context.WithCancel(ctx)
done2() done2()
@ -712,7 +712,7 @@ func TestAlreadyCanceled(t *testing.T) {
} }
func TestHomogeneousGPUs(t *testing.T) { func TestHomogeneousGPUs(t *testing.T) {
ctx, done := context.WithTimeout(context.Background(), 100*time.Millisecond) ctx, done := context.WithTimeout(t.Context(), 100*time.Millisecond)
defer done() defer done()
s := InitScheduler(ctx) s := InitScheduler(ctx)