Skip to content

Commit

Permalink
test: migrate memcached to test-containers (#11176)
Browse files Browse the repository at this point in the history
  • Loading branch information
powersj authored and MyaLongmire committed Jul 6, 2022
1 parent c12d1e0 commit c7384d6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 0 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ services:
- xpack.security.enabled=false
ports:
- "9200:9200"
memcached:
image: memcached
ports:
- "11211:11211"
pgbouncer:
image: z9pascal/pgbouncer-container:1.15-latest
environment:
Expand Down
17 changes: 15 additions & 2 deletions plugins/inputs/memcached/memcached_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package memcached

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

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

"github.com/influxdata/telegraf/testutil"
)
Expand All @@ -15,13 +17,24 @@ func TestMemcachedGeneratesMetricsIntegration(t *testing.T) {
t.Skip("Skipping integration test in short mode")
}

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

m := &Memcached{
Servers: []string{testutil.GetLocalHost()},
Servers: []string{fmt.Sprintf("%s:%s", container.Address, container.Port)},
}

var acc testutil.Accumulator

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

intMetrics := []string{"get_hits", "get_misses", "evictions",
Expand Down

0 comments on commit c7384d6

Please sign in to comment.