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
|
- xpack.security.enabled=false
|
||||||
ports:
|
ports:
|
||||||
- "9200:9200"
|
- "9200:9200"
|
||||||
memcached:
|
|
||||||
image: memcached
|
|
||||||
ports:
|
|
||||||
- "11211:11211"
|
|
||||||
pgbouncer:
|
pgbouncer:
|
||||||
image: z9pascal/pgbouncer-container:1.15-latest
|
image: z9pascal/pgbouncer-container:1.15-latest
|
||||||
environment:
|
environment:
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,12 @@ package memcached
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
"github.com/testcontainers/testcontainers-go/wait"
|
||||||
|
|
||||||
"github.com/influxdata/telegraf/testutil"
|
"github.com/influxdata/telegraf/testutil"
|
||||||
)
|
)
|
||||||
|
|
@ -15,13 +17,24 @@ func TestMemcachedGeneratesMetricsIntegration(t *testing.T) {
|
||||||
t.Skip("Skipping integration test in short mode")
|
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{
|
m := &Memcached{
|
||||||
Servers: []string{testutil.GetLocalHost()},
|
Servers: []string{fmt.Sprintf("%s:%s", container.Address, container.Port)},
|
||||||
}
|
}
|
||||||
|
|
||||||
var acc testutil.Accumulator
|
var acc testutil.Accumulator
|
||||||
|
|
||||||
err := acc.GatherError(m.Gather)
|
err = acc.GatherError(m.Gather)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
intMetrics := []string{"get_hits", "get_misses", "evictions",
|
intMetrics := []string{"get_hits", "get_misses", "evictions",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue