Tests: OPCUA tests can now use OPCUA_DEFAULT_HOST environment variable to force host to something else than "127.0.0.1" or "localhost" wxPython4
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Wed, 01 Feb 2023 20:43:35 +0100
branchwxPython4
changeset 3718 7841b651d601
parent 3717 da9ffd572551
child 3719 4906295e0be6
Tests: OPCUA tests can now use OPCUA_DEFAULT_HOST environment variable to force host to something else than "127.0.0.1" or "localhost"
opc_ua/client.py
tests/cli_tests/opcua_test.bash
tests/cli_tests/opcua_test_encrypted.bash
tests/ide_tests/opcua_browse.sikuli/opcua_service.bash
tests/ide_tests/opcua_browse_encrypted.sikuli/opcua_service.bash
--- a/opc_ua/client.py	Mon Jan 16 16:22:44 2023 +0100
+++ b/opc_ua/client.py	Wed Feb 01 20:43:35 2023 +0100
@@ -22,6 +22,9 @@
     ("include",),
     ("arch",)]]
 
+# Tests need to use other default hosts
+OPCUA_DEFAULT_HOST = os.environ.get("OPCUA_DEFAULT_HOST", "127.0.0.1")
+
 class OPCUAClientEditor(ConfTreeNodeEditor):
     CONFNODEEDITOR_TABS = [
         (_("OPC-UA Client"), "CreateOPCUAClient_UI")]
@@ -79,7 +82,7 @@
               </xsd:complexType>
             </xsd:element>
           </xsd:sequence>
-          <xsd:attribute name="Server_URI" type="xsd:string" use="optional" default="opc.tcp://localhost:4840"/>
+          <xsd:attribute name="Server_URI" type="xsd:string" use="optional" default="opc.tcp://"""+OPCUA_DEFAULT_HOST+""":4840"/>
         </xsd:complexType>
       </xsd:element>
     </xsd:schema>
--- a/tests/cli_tests/opcua_test.bash	Mon Jan 16 16:22:44 2023 +0100
+++ b/tests/cli_tests/opcua_test.bash	Wed Feb 01 20:43:35 2023 +0100
@@ -17,12 +17,15 @@
 ) << EOF &
 
 import sys
+import os
 import time
 
 from opcua import ua, Server
 
 server = Server()
-server.set_endpoint("opc.tcp://127.0.0.1:4840/freeopcua/server/")
+host = os.environ.get("OPCUA_DEFAULT_HOST", "127.0.0.1")
+endpoint = "opc.tcp://"+host+":4840/freeopcua/server/"
+server.set_endpoint(endpoint)
 
 uri = "http://beremiz.github.io"
 idx = server.register_namespace(uri)
--- a/tests/cli_tests/opcua_test_encrypted.bash	Mon Jan 16 16:22:44 2023 +0100
+++ b/tests/cli_tests/opcua_test_encrypted.bash	Wed Feb 01 20:43:35 2023 +0100
@@ -22,12 +22,15 @@
 ) << EOF &
 
 import sys
+import os
 import time
 
 from opcua import ua, Server
 
 server = Server()
-server.set_endpoint("opc.tcp://127.0.0.1:4840/freeopcua/server/")
+host = os.environ.get("OPCUA_DEFAULT_HOST", "127.0.0.1")
+endpoint = "opc.tcp://"+host+":4840/freeopcua/server/"
+server.set_endpoint(endpoint)
 
 server.set_security_policy([ua.SecurityPolicyType.Basic256Sha256_SignAndEncrypt])
 server.load_certificate("my_cert.der")
--- a/tests/ide_tests/opcua_browse.sikuli/opcua_service.bash	Mon Jan 16 16:22:44 2023 +0100
+++ b/tests/ide_tests/opcua_browse.sikuli/opcua_service.bash	Wed Feb 01 20:43:35 2023 +0100
@@ -6,12 +6,15 @@
 exec $BEREMIZPYTHONPATH - << EOF
 
 import sys
+import os
 import time
 
 from opcua import ua, Server
 
 server = Server()
-server.set_endpoint("opc.tcp://127.0.0.1:4840/freeopcua/server/")
+host = os.environ.get("OPCUA_DEFAULT_HOST", "127.0.0.1")
+endpoint = "opc.tcp://"+host+":4840/freeopcua/server/"
+server.set_endpoint(endpoint)
 
 uri = "http://beremiz.github.io"
 idx = server.register_namespace(uri)
--- a/tests/ide_tests/opcua_browse_encrypted.sikuli/opcua_service.bash	Mon Jan 16 16:22:44 2023 +0100
+++ b/tests/ide_tests/opcua_browse_encrypted.sikuli/opcua_service.bash	Wed Feb 01 20:43:35 2023 +0100
@@ -16,12 +16,15 @@
 exec $BEREMIZPYTHONPATH - << EOF
 
 import sys
+import os
 import time
 
 from opcua import ua, Server
 
 server = Server()
-server.set_endpoint("opc.tcp://127.0.0.1:4840/freeopcua/server/")
+host = os.environ.get("OPCUA_DEFAULT_HOST", "127.0.0.1")
+endpoint = "opc.tcp://"+host+":4840/freeopcua/server/"
+server.set_endpoint(endpoint)
 
 server.set_security_policy([ua.SecurityPolicyType.Basic256Sha256_SignAndEncrypt])
 server.load_certificate("my_cert.der")