test(inputs.opcua_listener): harden tests (#12193)

This commit is contained in:
Joshua Powers 2022-11-07 13:31:07 -07:00 committed by GitHub
parent 9d18c973cf
commit 42e2c2deff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 8 deletions

View File

@ -40,7 +40,10 @@ func TestGetDataBadNodeContainerIntegration(t *testing.T) {
container := testutil.Container{
Image: "open62541/open62541",
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()
require.NoError(t, err, "failed to start container")
@ -95,7 +98,6 @@ func TestGetDataBadNodeContainerIntegration(t *testing.T) {
err = readClient.Connect()
require.NoError(t, err)
require.Contains(t, logger.LastError, "E! [] status not OK for node ProductName")
}
func TestReadClientIntegration(t *testing.T) {
@ -106,7 +108,10 @@ func TestReadClientIntegration(t *testing.T) {
container := testutil.Container{
Image: "open62541/open62541",
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()
require.NoError(t, err, "failed to start container")
@ -187,7 +192,7 @@ password = ""
name="name2"
namespace="2"
identifier_type="s"
identifier="two"
identifier="two"
tags=[["tag0", "val0"], ["tag00", "val00"]]
default_tags = {tag6 = "val6"}

View File

@ -41,7 +41,10 @@ func TestSubscribeClientIntegration(t *testing.T) {
container := testutil.Container{
Image: "open62541/open62541",
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()
require.NoError(t, err, "failed to start container")
@ -87,10 +90,14 @@ func TestSubscribeClientIntegration(t *testing.T) {
o, err := subscribeConfig.CreateSubscribeClient(testutil.Logger{})
require.NoError(t, err)
err = o.Init()
require.NoError(t, err, "Initialization")
// give init a couple extra attempts, seconds as on CircleCI this can
// be attempted to soon
require.Eventually(t, func() bool {
return o.Init() == nil
}, 5*time.Second, 10*time.Millisecond)
err = o.Connect()
require.NoError(t, err, "Connect")
require.NoError(t, err, "Connection failed")
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()