test(inputs.opcua_listener): harden tests (#12193)
This commit is contained in:
parent
9d18c973cf
commit
42e2c2deff
|
|
@ -40,7 +40,10 @@ func TestGetDataBadNodeContainerIntegration(t *testing.T) {
|
||||||
container := testutil.Container{
|
container := testutil.Container{
|
||||||
Image: "open62541/open62541",
|
Image: "open62541/open62541",
|
||||||
ExposedPorts: []string{servicePort},
|
ExposedPorts: []string{servicePort},
|
||||||
WaitingFor: wait.ForListeningPort(nat.Port(servicePort)),
|
WaitingFor: wait.ForAll(
|
||||||
|
wait.ForListeningPort(nat.Port(servicePort)),
|
||||||
|
wait.ForLog("TCP network layer listening on opc.tcp://"),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
err := container.Start()
|
err := container.Start()
|
||||||
require.NoError(t, err, "failed to start container")
|
require.NoError(t, err, "failed to start container")
|
||||||
|
|
@ -95,7 +98,6 @@ func TestGetDataBadNodeContainerIntegration(t *testing.T) {
|
||||||
|
|
||||||
err = readClient.Connect()
|
err = readClient.Connect()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Contains(t, logger.LastError, "E! [] status not OK for node ProductName")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReadClientIntegration(t *testing.T) {
|
func TestReadClientIntegration(t *testing.T) {
|
||||||
|
|
@ -106,7 +108,10 @@ func TestReadClientIntegration(t *testing.T) {
|
||||||
container := testutil.Container{
|
container := testutil.Container{
|
||||||
Image: "open62541/open62541",
|
Image: "open62541/open62541",
|
||||||
ExposedPorts: []string{servicePort},
|
ExposedPorts: []string{servicePort},
|
||||||
WaitingFor: wait.ForListeningPort(nat.Port(servicePort)),
|
WaitingFor: wait.ForAll(
|
||||||
|
wait.ForListeningPort(nat.Port(servicePort)),
|
||||||
|
wait.ForLog("TCP network layer listening on opc.tcp://"),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
err := container.Start()
|
err := container.Start()
|
||||||
require.NoError(t, err, "failed to start container")
|
require.NoError(t, err, "failed to start container")
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,10 @@ func TestSubscribeClientIntegration(t *testing.T) {
|
||||||
container := testutil.Container{
|
container := testutil.Container{
|
||||||
Image: "open62541/open62541",
|
Image: "open62541/open62541",
|
||||||
ExposedPorts: []string{servicePort},
|
ExposedPorts: []string{servicePort},
|
||||||
WaitingFor: wait.ForListeningPort(nat.Port(servicePort)),
|
WaitingFor: wait.ForAll(
|
||||||
|
wait.ForListeningPort(nat.Port(servicePort)),
|
||||||
|
wait.ForLog("TCP network layer listening on opc.tcp://"),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
err := container.Start()
|
err := container.Start()
|
||||||
require.NoError(t, err, "failed to start container")
|
require.NoError(t, err, "failed to start container")
|
||||||
|
|
@ -87,10 +90,14 @@ func TestSubscribeClientIntegration(t *testing.T) {
|
||||||
o, err := subscribeConfig.CreateSubscribeClient(testutil.Logger{})
|
o, err := subscribeConfig.CreateSubscribeClient(testutil.Logger{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
err = o.Init()
|
// give init a couple extra attempts, seconds as on CircleCI this can
|
||||||
require.NoError(t, err, "Initialization")
|
// be attempted to soon
|
||||||
|
require.Eventually(t, func() bool {
|
||||||
|
return o.Init() == nil
|
||||||
|
}, 5*time.Second, 10*time.Millisecond)
|
||||||
|
|
||||||
err = o.Connect()
|
err = o.Connect()
|
||||||
require.NoError(t, err, "Connect")
|
require.NoError(t, err, "Connection failed")
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue