Skip to content

Commit

Permalink
Fix sporadic in probe tests
Browse files Browse the repository at this point in the history
  • Loading branch information
afritzler committed Dec 5, 2024
1 parent 9ba115a commit 2b8f6d6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
17 changes: 0 additions & 17 deletions internal/probe/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,16 @@
package probe_test

import (
"context"
"encoding/json"
"fmt"
"net/http"
"time"

"github.com/ironcore-dev/metal-operator/internal/probe"

"github.com/ironcore-dev/metal-operator/internal/api/registry"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("ProbeAgent", func() {
BeforeEach(func() {
By("Starting the probe agent")
ctx, cancel := context.WithCancel(context.Background())
DeferCleanup(cancel)

// Initialize your probe agent
probeAgent = probe.NewAgent(systemUUID, registryURL, 100*time.Millisecond)
go func() {
defer GinkgoRecover()
Expect(probeAgent.Start(ctx)).To(Succeed(), "failed to start probe agent")
}()
})

It("should ensure the correct endpoints have been registered", func() {
By("performing a GET request to the /systems/{uuid} endpoint")
var resp *http.Response
Expand Down
6 changes: 6 additions & 0 deletions internal/probe/probe_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package probe_test

import (
"context"
"net/http"
"testing"
"time"

Expand Down Expand Up @@ -43,6 +44,11 @@ var _ = BeforeSuite(func() {
Expect(registryServer.Start(ctx)).To(Succeed(), "failed to start registry agent")
}()

Eventually(func() error {
_, err := http.Get(registryAddr)
return err
}).Should(Succeed())

// Initialize your probe server
probeAgent = probe.NewAgent(systemUUID, registryURL, 100*time.Millisecond)
go func() {
Expand Down
6 changes: 6 additions & 0 deletions internal/registry/registry_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package registry_test

import (
"context"
"net/http"
"testing"

"github.com/ironcore-dev/metal-operator/internal/registry"
Expand Down Expand Up @@ -36,4 +37,9 @@ var _ = BeforeSuite(func() {
defer GinkgoRecover()
Expect(server.Start(ctx)).To(Succeed(), "failed to start registry server")
}()

Eventually(func() error {
_, err := http.Get(testServerURL)
return err
}).Should(Succeed())
})

0 comments on commit 2b8f6d6

Please sign in to comment.