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(test): ensure some more clients are closed #2595

Merged
merged 2 commits into from
Aug 12, 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
3 changes: 2 additions & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
)

func safeClose(t testing.TB, c io.Closer) {
t.Helper()
err := c.Close()
if err != nil {
t.Error(err)
Expand Down Expand Up @@ -51,6 +52,7 @@ func TestCachedPartitions(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer safeClose(t, c)
client := c.(*client)

// Verify they aren't cached the same
Expand All @@ -69,7 +71,6 @@ func TestCachedPartitions(t *testing.T) {
}

seedBroker.Close()
safeClose(t, client)
}

func TestClientDoesntCachePartitionsForTopicsWithErrors(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions functional_producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ func TestFuncTxnAbortedProduce(t *testing.T) {

client, err := NewClient(FunctionalTestEnv.KafkaBrokerAddrs, config)
require.NoError(t, err)
defer client.Close()

consumer, err := NewConsumerFromClient(client)
require.NoError(t, err)
Expand Down Expand Up @@ -745,6 +746,7 @@ func TestInterceptors(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer safeClose(t, client)

initialOffset, err := client.GetOffset("test.1", 0, OffsetNewest)
if err != nil {
Expand Down Expand Up @@ -800,7 +802,6 @@ func TestInterceptors(t *testing.T) {
}
}
safeClose(t, consumer)
safeClose(t, client)
}

func testProducingMessages(t *testing.T, config *Config) {
Expand All @@ -821,6 +822,7 @@ func testProducingMessages(t *testing.T, config *Config) {
if err != nil {
t.Fatal(err)
}
defer safeClose(t, client)

// Keep in mind the current offset
initialOffset, err := client.GetOffset("test.1", 0, OffsetNewest)
Expand Down Expand Up @@ -885,7 +887,6 @@ func testProducingMessages(t *testing.T, config *Config) {
validateConsumerMetrics(t, client)

safeClose(t, consumer)
safeClose(t, client)
}

// TestAsyncProducerRemoteBrokerClosed ensures that the async producer can
Expand Down
3 changes: 2 additions & 1 deletion internal/toxiproxy/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ func NewClient(endpoint string) *Client {
KeepAlive: 30 * time.Second,
}).DialContext,
ForceAttemptHTTP2: true,
MaxIdleConns: 100,
MaxIdleConns: -1,
DisableKeepAlives: true,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
Expand Down
Loading