Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sporadic in probe tests #193

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Check if anything is using port 8080 and kill it
run: |
if lsof -i :8080; then
echo "Port 8080 is in use by:"
lsof -i :8080
echo "Killing process using port 8080..."
kill -9 $(lsof -t -i :8080)
else
echo "Port 8080 is not in use."
fi

- run: make test
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(registryURL)
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())
})
Loading