test: migrate memcached to test-containers (#11176)

This commit is contained in:
Joshua Powers 2022-05-24 09:30:29 -06:00 committed by GitHub
parent cb9d9fe075
commit 59a7f76117
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View File

@ -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:

View File

@ -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"
)
@ -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",