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: kafka batch integration test #4146

Merged
merged 2 commits into from
Nov 16, 2023
Merged
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
37 changes: 9 additions & 28 deletions integration_test/kafka_batching/kafka_batching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,24 @@ import (
"testing"
"time"

"golang.org/x/sync/errgroup"

"github.com/go-chi/chi/v5"
"github.com/ory/dockertest/v3"
promClient "github.com/prometheus/client_model/go"
"github.com/stretchr/testify/require"
"golang.org/x/sync/errgroup"

"github.com/rudderlabs/rudder-go-kit/stats/testhelper"
kithelper "github.com/rudderlabs/rudder-go-kit/testhelper"
"github.com/rudderlabs/rudder-go-kit/testhelper/docker/resource"
"github.com/rudderlabs/rudder-go-kit/testhelper/rand"

"github.com/rudderlabs/rudder-server/app"
kafkaClient "github.com/rudderlabs/rudder-server/services/streammanager/kafka/client"
"github.com/rudderlabs/rudder-server/services/streammanager/kafka/client/testutil"
th "github.com/rudderlabs/rudder-server/testhelper"
"github.com/rudderlabs/rudder-server/testhelper/destination"
"github.com/rudderlabs/rudder-server/testhelper/destination/kafka"
thEtcd "github.com/rudderlabs/rudder-server/testhelper/etcd"
"github.com/rudderlabs/rudder-server/testhelper/health"
"github.com/rudderlabs/rudder-server/utils/httputil"
"github.com/rudderlabs/rudder-server/utils/types/deployment"
)
Expand Down Expand Up @@ -181,7 +180,9 @@ func TestKafkaBatching(t *testing.T) {
"RSERVER_WAREHOUSE_MODE=off",
)
if testing.Verbose() {
cmd.Env = append(cmd.Env, "LOG_LEVEL=debug")
cmd.Env = append(cmd.Env, "LOG_LEVEL=DEBUG")
} else {
cmd.Env = append(cmd.Env, "LOG_LEVEL=INFO")
}

stdout, err := cmd.StdoutPipe()
Expand Down Expand Up @@ -210,30 +211,10 @@ func TestKafkaBatching(t *testing.T) {
t.Cleanup(func() { cancel(); <-done })

// Waiting for RS to become healthy
var (
resp *http.Response
respBody string
statusCode int
healthEndpoint = fmt.Sprintf("http://localhost:%d/health", httpPort)
health.WaitUntilReady(context.Background(), t,
fmt.Sprintf("http://localhost:%d/health", httpPort),
2*time.Minute, time.Second, t.Name(),
)
require.Eventuallyf(t, func() bool {
resp, err = http.Get(healthEndpoint)
if err != nil {
return false
}
defer func() { httputil.CloseResponse(resp) }()

var buf []byte
buf, err = io.ReadAll(resp.Body)
if err != nil {
return false
}
respBody = string(buf)
if statusCode = resp.StatusCode; statusCode != http.StatusOK {
return false
}
return true
}, time.Minute, 100*time.Millisecond, "RS did not become healthy in time (%s)[%d]: %v", respBody, statusCode, err)

noOfMessages := 10
for i := 0; i < noOfMessages; i++ {
Expand Down Expand Up @@ -279,7 +260,7 @@ func TestKafkaBatching(t *testing.T) {

var buf []byte
require.Eventuallyf(t, func() bool {
resp, err = http.Get(fmt.Sprintf("http://localhost:%d/metrics", prometheusPort))
resp, err := http.Get(fmt.Sprintf("http://localhost:%d/metrics", prometheusPort))
require.NoError(t, err)
defer func() { httputil.CloseResponse(resp) }()

Expand Down
Loading