test: migrate memcached to test-containers (#11176)
This commit is contained in:
parent
cb9d9fe075
commit
59a7f76117
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Reference in New Issue