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

chore: adapt health.WaitUntilReady #4081

Merged
merged 2 commits into from
Nov 6, 2023
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
32 changes: 4 additions & 28 deletions warehouse/api/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"testing"
"time"

"github.com/rudderlabs/rudder-server/testhelper/health"

"github.com/rudderlabs/rudder-go-kit/stats/memstats"

"github.com/rudderlabs/rudder-server/warehouse/internal/mode"
Expand Down Expand Up @@ -772,20 +774,7 @@ func TestHTTPApi(t *testing.T) {
serverURL := fmt.Sprintf("http://localhost:%d", webPort)

t.Run("health", func(t *testing.T) {
require.Eventually(t, func() bool {
resp, err := http.Get(fmt.Sprintf("%s/health", serverURL))
if err != nil {
return false
}
defer func() {
httputil.CloseResponse(resp)
}()

return resp.StatusCode == http.StatusOK
},
time.Second*10,
time.Second,
)
health.WaitUntilReady(ctx, t, fmt.Sprintf("%s/health", serverURL), time.Second*10, time.Millisecond*100, t.Name())
})

t.Run("process", func(t *testing.T) {
Expand Down Expand Up @@ -971,20 +960,7 @@ func TestHTTPApi(t *testing.T) {
serverURL := fmt.Sprintf("http://localhost:%d", webPort)

t.Run("health endpoint should work", func(t *testing.T) {
require.Eventually(t, func() bool {
resp, err := http.Get(fmt.Sprintf("%s/health", serverURL))
if err != nil {
return false
}
defer func() {
httputil.CloseResponse(resp)
}()

return resp.StatusCode == http.StatusOK
},
time.Second*10,
time.Second,
)
health.WaitUntilReady(ctx, t, fmt.Sprintf("%s/health", serverURL), time.Second*10, time.Millisecond*100, t.Name())
})

t.Run("other endpoints should fail", func(t *testing.T) {
Expand Down
40 changes: 4 additions & 36 deletions warehouse/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"context"
"fmt"
"net"
"net/http"
"strconv"
"testing"
"time"

"github.com/rudderlabs/rudder-server/testhelper/health"
fracasula marked this conversation as resolved.
Show resolved Hide resolved

"github.com/rudderlabs/rudder-go-kit/stats/memstats"

"github.com/rudderlabs/rudder-server/warehouse/internal/mode"
Expand Down Expand Up @@ -41,7 +42,6 @@ import (
"github.com/rudderlabs/rudder-server/enterprise/reporting"
mocksApp "github.com/rudderlabs/rudder-server/mocks/app"
mocksBackendConfig "github.com/rudderlabs/rudder-server/mocks/backend-config"
"github.com/rudderlabs/rudder-server/utils/httputil"
"github.com/rudderlabs/rudder-server/utils/misc"
"github.com/rudderlabs/rudder-server/utils/pubsub"
whutils "github.com/rudderlabs/rudder-server/warehouse/utils"
Expand Down Expand Up @@ -142,23 +142,7 @@ func TestApp(t *testing.T) {
})
g.Go(func() error {
defer stopServer()

serverURL := fmt.Sprintf("http://localhost:%d", webPort)

require.Eventually(t, func() bool {
resp, err := http.Get(fmt.Sprintf("%s/health", serverURL))
if err != nil {
return false
}
defer func() {
httputil.CloseResponse(resp)
}()

return resp.StatusCode == http.StatusOK
},
time.Second*10,
time.Millisecond*100,
)
health.WaitUntilReady(ctx, t, fmt.Sprintf("http://localhost:%d/health", webPort), time.Second*10, time.Millisecond*100, t.Name())
return nil
})
require.NoError(t, g.Wait())
Expand Down Expand Up @@ -428,23 +412,7 @@ func TestApp(t *testing.T) {
})
g.Go(func() error {
defer stopServer()

serverURL := fmt.Sprintf("http://localhost:%d", webPort)

require.Eventually(t, func() bool {
resp, err := http.Get(fmt.Sprintf("%s/health", serverURL))
if err != nil {
return false
}
defer func() {
httputil.CloseResponse(resp)
}()

return resp.StatusCode == http.StatusOK
},
time.Second*10,
time.Second,
)
health.WaitUntilReady(ctx, t, fmt.Sprintf("http://localhost:%d/health", webPort), time.Second*10, time.Millisecond*100, t.Name())
return nil
})
require.NoError(t, g.Wait())
Expand Down
Loading