This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new 041bf58d34 test(plc4go): close connections in DriverTestRunner at the 
end
041bf58d34 is described below

commit 041bf58d34be34f190ebb1f4510d15014babea8a
Author: Sebastian Rühl <sru...@apache.org>
AuthorDate: Thu Aug 3 12:47:33 2023 +0200

    test(plc4go): close connections in DriverTestRunner at the end
    
    this should prevent errors like: panic: Log in goroutine after 
TestOPCUADriver
---
 plc4go/spi/testutils/DriverTestRunner.go | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/plc4go/spi/testutils/DriverTestRunner.go 
b/plc4go/spi/testutils/DriverTestRunner.go
index 73c859f15a..ce2c95cec4 100644
--- a/plc4go/spi/testutils/DriverTestRunner.go
+++ b/plc4go/spi/testutils/DriverTestRunner.go
@@ -118,6 +118,18 @@ func (m DriverTestsuite) Run(t *testing.T, driverManager 
plc4go.PlcDriverManager
                return errors.Wrap(connectionResult.GetErr(), "error getting a 
connection")
        }
        connection := connectionResult.GetConnection()
+       t.Cleanup(func() {
+               timeout := time.NewTimer(30 * time.Second)
+               t.Cleanup(func() {
+                       utils.CleanupTimer(timeout)
+               })
+               select {
+               case result := <-connection.Close():
+                       assert.NoError(t, result.GetErr())
+               case <-timeout.C:
+                       t.Error("timeout closing connection")
+               }
+       })
        utils.NewAsciiBoxWriter()
        m.LogDelimiterSection(t, "=", "Executing testcase: %s", testcase.name)
 

Reply via email to