From 5647ac91b297f77938cb25f02bdd308f2f9278a4 Mon Sep 17 00:00:00 2001 From: Daniel Hiltgen Date: Thu, 25 Sep 2025 09:53:22 -0700 Subject: [PATCH] test: harden integration tests for slow start If the server takes a while to start up, block tests from starting until it's online to avoid setting large timeouts in individual test cases. --- integration/utils_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/integration/utils_test.go b/integration/utils_test.go index 7901fed3f..bfbae19e7 100644 --- a/integration/utils_test.go +++ b/integration/utils_test.go @@ -440,6 +440,24 @@ func InitServerConnection(ctx context.Context, t *testing.T) (*api.Client, strin t.Fatal(err) } } + // Make sure server is online and healthy before returning + listCtx, cancel := context.WithDeadlineCause( + ctx, + time.Now().Add(120*time.Second), + fmt.Errorf("list models took too long"), + ) + defer cancel() + models, err := client.ListRunning(listCtx) + if err != nil { + t.Fatal(err) + } + if len(models.Models) > 0 { + names := make([]string, len(models.Models)) + for i, m := range models.Models { + names[i] = m.Name + } + slog.Info("currently loaded", "models", names) + } return client, testEndpoint, func() { if os.Getenv("OLLAMA_TEST_EXISTING") == "" {