From 5111738b3b2971de008da49f0bc01fbfa371a87a Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Tue, 8 Apr 2025 22:45:15 +0200 Subject: [PATCH] Wait for API to be ready --- core/agent/agent_test.go | 10 ++++++++++ tests/e2e/e2e_test.go | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/core/agent/agent_test.go b/core/agent/agent_test.go index c02ee3f..3e22c1a 100644 --- a/core/agent/agent_test.go +++ b/core/agent/agent_test.go @@ -3,6 +3,7 @@ package agent_test import ( "context" "fmt" + "net/http" "strings" "sync" @@ -112,6 +113,15 @@ func (a *FakeInternetAction) Definition() types.ActionDefinition { var _ = Describe("Agent test", func() { Context("jobs", func() { + + BeforeEach(func() { + Eventually(func() error { + // test apiURL is working and available + _, err := http.Get(apiURL + "/readyz") + return err + }, "10m", "10s").ShouldNot(HaveOccurred()) + }) + It("pick the correct action", func() { agent, err := New( WithLLMAPIURL(apiURL), diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index dcf6298..52c2a6c 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -1,6 +1,7 @@ package e2e_test import ( + "net/http" "time" localagi "github.com/mudler/LocalAGI/pkg/client" @@ -11,6 +12,14 @@ import ( var _ = Describe("Agent test", func() { Context("Creates an agent and it answers", func() { + BeforeEach(func() { + Eventually(func() error { + // test apiURL is working and available + _, err := http.Get(apiURL + "/readyz") + return err + }, "10m", "10s").ShouldNot(HaveOccurred()) + }) + It("create agent", func() { client := localagi.NewClient(localagiURL, "", 5*time.Minute)