test: migrate nsq to test containers (#11173)
This commit is contained in:
parent
d5ff34bc14
commit
5857966df1
|
|
@ -45,11 +45,6 @@ services:
|
|||
ports:
|
||||
- "15672:15672"
|
||||
- "5672:5672"
|
||||
nsq:
|
||||
image: nsqio/nsq
|
||||
ports:
|
||||
- "4150:4150"
|
||||
command: "/nsqd"
|
||||
openldap:
|
||||
image: cobaugh/openldap-alpine
|
||||
environment:
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
package nsq
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/influxdata/telegraf/plugins/serializers"
|
||||
"github.com/influxdata/telegraf/testutil"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/testcontainers/testcontainers-go/wait"
|
||||
)
|
||||
|
||||
func TestConnectAndWriteIntegration(t *testing.T) {
|
||||
|
|
@ -13,7 +15,19 @@ func TestConnectAndWriteIntegration(t *testing.T) {
|
|||
t.Skip("Skipping integration test in short mode")
|
||||
}
|
||||
|
||||
server := []string{testutil.GetLocalHost() + ":4150"}
|
||||
container := testutil.Container{
|
||||
Image: "nsqio/nsq",
|
||||
ExposedPorts: []string{"4150"},
|
||||
Entrypoint: []string{"/nsqd"},
|
||||
WaitingFor: wait.ForListeningPort("4150/tcp"),
|
||||
}
|
||||
err := container.Start()
|
||||
require.NoError(t, err, "failed to start container")
|
||||
defer func() {
|
||||
require.NoError(t, container.Terminate(), "terminating container failed")
|
||||
}()
|
||||
|
||||
server := []string{fmt.Sprintf("%s:%s", container.Address, container.Port)}
|
||||
s, _ := serializers.NewInfluxSerializer()
|
||||
n := &NSQ{
|
||||
Server: server[0],
|
||||
|
|
@ -22,7 +36,7 @@ func TestConnectAndWriteIntegration(t *testing.T) {
|
|||
}
|
||||
|
||||
// Verify that we can connect to the NSQ daemon
|
||||
err := n.Connect()
|
||||
err = n.Connect()
|
||||
require.NoError(t, err)
|
||||
|
||||
// Verify that we can successfully write data to the NSQ daemon
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ func (c *Container) Start() error {
|
|||
Image: c.Image,
|
||||
Env: c.Env,
|
||||
ExposedPorts: c.ExposedPorts,
|
||||
WaitingFor: c.WaitingFor,
|
||||
Entrypoint: c.Entrypoint,
|
||||
WaitingFor: c.WaitingFor,
|
||||
},
|
||||
Started: true,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue