Skip to content

Commit

Permalink
test: migrate mcrouter to test-containers (#11208)
Browse files Browse the repository at this point in the history
  • Loading branch information
powersj authored and MyaLongmire committed Jul 6, 2022
1 parent f9cb7c0 commit 6f40037
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions plugins/inputs/mcrouter/mcrouter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package mcrouter

import (
"bufio"
"fmt"
"strings"
"testing"

"github.com/docker/go-connections/nat"
"github.com/stretchr/testify/require"
"github.com/testcontainers/testcontainers-go/wait"

"github.com/influxdata/telegraf/testutil"
)
Expand Down Expand Up @@ -49,13 +52,27 @@ func TestMcrouterGeneratesMetricsIntegration(t *testing.T) {
t.Skip("Skipping integration test in short mode")
}

servicePort := "11211"
container := testutil.Container{
Image: "memcached",
ExposedPorts: []string{servicePort},
WaitingFor: wait.ForListeningPort(nat.Port(servicePort)),
}
err := container.Start()
require.NoError(t, err, "failed to start container")
defer func() {
require.NoError(t, container.Terminate(), "terminating container failed")
}()

m := &Mcrouter{
Servers: []string{"tcp://" + testutil.GetLocalHost()},
Servers: []string{
fmt.Sprintf("tcp://%s:%s", container.Address, container.Ports[servicePort]),
},
}

var acc testutil.Accumulator

err := acc.GatherError(m.Gather)
err = acc.GatherError(m.Gather)
require.NoError(t, err)

intMetrics := []string{
Expand Down

0 comments on commit 6f40037

Please sign in to comment.