Skip to content

Commit

Permalink
Merge pull request #2595 from IBM/dnwe/close
Browse files Browse the repository at this point in the history
fix(test): ensure some more clients are closed
  • Loading branch information
dnwe authored Aug 12, 2023
2 parents 45313c3 + b0363d1 commit 868ed33
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
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

0 comments on commit 868ed33

Please sign in to comment.