Skip to content
Open
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
1 change: 1 addition & 0 deletions backend/pkg/api/api_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func (s *APIIntegrationTestSuite) SetupSuite() {

ctx := context.Background()
container, err := redpanda.Run(ctx, testutil.RedpandaImage())
testutil.LogContainerLogsIfFailed(ctx, t, container, err)
require.NoError(err)
s.redpandaContainer = container

Expand Down
2 changes: 2 additions & 0 deletions backend/pkg/api/connect/integration/api_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func (s *APISuite) SetupSuite() {
network.WithNetwork([]string{"redpanda"}, s.network),
redpanda.WithListener("redpanda:29092"),
)
testutil.LogContainerLogsIfFailed(ctx, t, container, err)
require.NoError(err)
s.redpandaContainer = container

Expand All @@ -99,6 +100,7 @@ func (s *APISuite) SetupSuite() {
[]string{"redpanda:29092"},
network.WithNetwork([]string{"kconnect"}, s.network),
)
testutil.LogContainerLogsIfFailed(ctx, t, kConnectContainer, err)
require.NoError(err)

s.kConnectContainer = kConnectContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ func (s *APISuite) TestGetConnectorAndStatus_v1() {

// Run HTTPBin container
httpC, err := testutil.RunHTTPBinContainer(ctx, network.WithNetwork([]string{"httpbin", "local-httpbin"}, s.network))
testutil.LogContainerLogsIfFailed(ctx, t, httpC, err)
requireT.NoError(err)

client := v1connect.NewKafkaConnectServiceClient(http.DefaultClient, s.httpAddress())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ func (s *APISuite) TestGetConnectorAndStatus_v1alpha2() {

// Run HTTPBin container
httpC, err := testutil.RunHTTPBinContainer(ctx, network.WithNetwork([]string{"httpbin", "local-httpbin"}, s.network))
testutil.LogContainerLogsIfFailed(ctx, t, httpC, err)
requireT.NoError(err)

client := v1alpha2connect.NewKafkaConnectServiceClient(http.DefaultClient, s.httpAddress())
Expand Down
2 changes: 2 additions & 0 deletions backend/pkg/api/handle_kafka_connect_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (s *APIIntegrationTestSuite) TestHandleCreateConnector() {
network.WithNetwork([]string{"redpanda"}, testNetwork),
redpanda.WithListener("redpanda:29092"),
)
testutil.LogContainerLogsIfFailed(ctx, t, redpandaContainer, err)
require.NoError(err)

seedBroker, err := redpandaContainer.KafkaSeedBroker(ctx)
Expand All @@ -68,6 +69,7 @@ func (s *APIIntegrationTestSuite) TestHandleCreateConnector() {
network.WithNetwork([]string{"kafka-connect"}, testNetwork),
testcontainers.WithLogConsumers(logConsumer),
)
testutil.LogContainerLogsIfFailed(ctx, t, connectContainer, err)
require.NoError(err)

// Register cleanup in correct order: containers first, then network
Expand Down
1 change: 1 addition & 0 deletions backend/pkg/console/console_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (s *ConsoleIntegrationTestSuite) SetupSuite() {

ctx := context.Background()
container, err := redpanda.Run(ctx, testutil.RedpandaImage())
testutil.LogContainerLogsIfFailed(ctx, t, container, err)
require.NoError(err)
s.redpandaContainer = container

Expand Down
1 change: 1 addition & 0 deletions backend/pkg/serde/service_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func (s *SerdeIntegrationTestSuite) SetupSuite() {
ctx := t.Context()

redpandaContainer, err := redpanda.Run(ctx, testutil.RedpandaImage())
testutil.LogContainerLogsIfFailed(ctx, t, redpandaContainer, err)
require.NoError(err)

s.redpandaContainer = redpandaContainer
Expand Down
44 changes: 44 additions & 0 deletions backend/pkg/testutil/container.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2024 Redpanda Data, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2026?

//
// Use of this software is governed by the Business Source License
// included in the file https://github.com/redpanda-data/redpanda/blob/dev/licenses/bsl.md
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0

package testutil

import (
"context"
"io"
"testing"

"github.com/testcontainers/testcontainers-go"
)

// LogContainerLogsIfFailed prints the container's logs to the test output when
// err is non-nil. This is useful for debugging container startup failures in CI,
// where the only clue is "container exited with code X" but no actual logs.
func LogContainerLogsIfFailed(ctx context.Context, t testing.TB, container testcontainers.Container, err error) {
t.Helper()

if err == nil || container == nil {
return
}

rc, logErr := container.Logs(ctx)
if logErr != nil {
t.Logf("failed to retrieve container logs after error: %v", logErr)
return
}
defer rc.Close()

logs, readErr := io.ReadAll(rc)
if readErr != nil {
t.Logf("failed to read container logs after error: %v", readErr)
return
}

t.Logf("container logs (startup error: %v):\n%s", err, string(logs))
}
2 changes: 2 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,5 @@ dist

# Gemini CLI
.gemini/settings.json

tests/**/playwright-report/
Loading
Loading