Skip to content

Commit

Permalink
Explicitly close the test client too
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoriano committed Feb 20, 2020
1 parent cb06ac6 commit faaa97f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ import (
)

func TestAddDockerMetadata(t *testing.T) {
// Start a container to have some data to enrich an event
// Start a container to have some data to enrich events
testClient, err := dockertest.NewClient()
require.NoError(t, err)
defer testClient.Close()

image := "busybox"
cmd := []string{"sleep", "60"}
labels := map[string]string{"label": "foo"}
Expand All @@ -51,7 +53,7 @@ func TestAddDockerMetadata(t *testing.T) {
require.NoError(t, err)
pid := info.State.Pid

// Run the test under the goroutine leak checker
// Run the tests under the goroutine leak checker
resources.CallAndCheckGoroutines(t, func() {
// Explicitly close the docker client, what only closes the idle keep-alive connections.
// These idle connections affect the goroutines checker and will be eventually
Expand Down
5 changes: 5 additions & 0 deletions libbeat/tests/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,8 @@ func (c Client) ContainerKill(ID string) error {
ctx := context.Background()
return c.cli.ContainerKill(ctx, ID, "KILL")
}

// Close closes the underlying client
func (c *Client) Close() error {
return c.cli.Close()
}

0 comments on commit faaa97f

Please sign in to comment.