Commit 78d61807 authored by Mathias Lüdtke's avatar Mathias Lüdtke Committed by oroulet

[WORKAROUND] enforce IPv4 in travis tests

parent b6576153
......@@ -22,18 +22,18 @@ class TestClient(unittest.TestCase, CommonTests, SubscriptionTests, XmlTests):
def setUpClass(cls):
# start our own server
cls.srv = Server()
cls.srv.set_endpoint('opc.tcp://localhost:{0:d}'.format(port_num1))
cls.srv.set_endpoint('opc.tcp://127.0.0.1:{0:d}'.format(port_num1))
add_server_methods(cls.srv)
cls.srv.start()
# start admin client
# long timeout since travis (automated testing) can be really slow
cls.clt = Client('opc.tcp://admin@localhost:{0:d}'.format(port_num1), timeout=10)
cls.clt = Client('opc.tcp://admin@127.0.0.1:{0:d}'.format(port_num1), timeout=10)
cls.clt.connect()
cls.opc = cls.clt
# start anonymous client
cls.ro_clt = Client('opc.tcp://localhost:{0:d}'.format(port_num1))
cls.ro_clt = Client('opc.tcp://127.0.0.1:{0:d}'.format(port_num1))
cls.ro_clt.connect()
@classmethod
......
......@@ -15,7 +15,7 @@ class TestCmdLines(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.srv = Server()
cls.srv_url = 'opc.tcp://localhost:{0:d}'.format(port_num)
cls.srv_url = 'opc.tcp://127.0.0.1:{0:d}'.format(port_num)
cls.srv.set_endpoint(cls.srv_url)
objects = cls.srv.get_objects_node()
obj = objects.add_object(4, "directory")
......@@ -44,7 +44,7 @@ class TestCmdLines(unittest.TestCase):
def test_uadiscover(self):
s = subprocess.check_output(["python", "tools/uadiscover", "--url", self.srv_url])
self.assertIn(b"opc.tcp://localhost", s)
self.assertIn(b"opc.tcp://127.0.0.1", s)
self.assertIn(b"FreeOpcUa", s)
self.assertIn(b"urn:freeopcua:python:server", s)
......
......@@ -28,7 +28,7 @@ class TestCryptoConnect(unittest.TestCase):
def setUpClass(cls):
# start our own server
cls.srv_crypto = Server()
cls.uri_crypto = 'opc.tcp://localhost:{0:d}'.format(port_num1)
cls.uri_crypto = 'opc.tcp://127.0.0.1:{0:d}'.format(port_num1)
cls.srv_crypto.set_endpoint(cls.uri_crypto)
# load server certificate and private key. This enables endpoints
# with signing and encryption.
......@@ -38,7 +38,7 @@ class TestCryptoConnect(unittest.TestCase):
# start a server without crypto
cls.srv_no_crypto = Server()
cls.uri_no_crypto = 'opc.tcp://localhost:{0:d}'.format(port_num2)
cls.uri_no_crypto = 'opc.tcp://127.0.0.1:{0:d}'.format(port_num2)
cls.srv_no_crypto.set_endpoint(cls.uri_no_crypto)
cls.srv_no_crypto.start()
......
......@@ -24,10 +24,10 @@ class HistoryCommon(object):
@classmethod
def start_server_and_client(cls):
cls.srv = Server()
cls.srv.set_endpoint('opc.tcp://localhost:{0:d}'.format(port_num1))
cls.srv.set_endpoint('opc.tcp://127.0.0.1:{0:d}'.format(port_num1))
cls.srv.start()
cls.clt = Client('opc.tcp://localhost:{0:d}'.format(port_num1))
cls.clt = Client('opc.tcp://127.0.0.1:{0:d}'.format(port_num1))
cls.clt.connect()
@classmethod
......
......@@ -31,13 +31,13 @@ class TestServer(unittest.TestCase, CommonTests, SubscriptionTests, XmlTests):
@classmethod
def setUpClass(cls):
cls.srv = Server()
cls.srv.set_endpoint('opc.tcp://localhost:{0:d}'.format(port_num))
cls.srv.set_endpoint('opc.tcp://127.0.0.1:{0:d}'.format(port_num))
add_server_methods(cls.srv)
cls.srv.start()
cls.opc = cls.srv
cls.discovery = Server()
cls.discovery.set_application_uri("urn:freeopcua:python:discovery")
cls.discovery.set_endpoint('opc.tcp://localhost:{0:d}'.format(port_discovery))
cls.discovery.set_endpoint('opc.tcp://127.0.0.1:{0:d}'.format(port_discovery))
cls.discovery.start()
@classmethod
......@@ -200,7 +200,7 @@ class TestServer(unittest.TestCase, CommonTests, SubscriptionTests, XmlTests):
self.assertEqual(ev.ServerId, None)
self.assertEqual(ev.ClientAuditEntryId, None)
self.assertEqual(ev.ClientUserId, None)
def test_get_event_from_type_node_MultiInhereted_AuditOpenSecureChannelEvent(self):
ev = opcua.common.events.get_event_obj_from_type_node(opcua.Node(self.opc.iserver.isession, ua.NodeId(ua.ObjectIds.AuditOpenSecureChannelEventType)))
self.assertIsNot(ev, None)
......@@ -293,7 +293,7 @@ class TestServer(unittest.TestCase, CommonTests, SubscriptionTests, XmlTests):
self.assertEqual(ev.ServerId, None)
self.assertEqual(ev.ClientAuditEntryId, None)
self.assertEqual(ev.ClientUserId, None)
def test_eventgenerator_MultiInheritedEvent(self):
evgen = self.opc.get_event_generator(ua.ObjectIds.AuditOpenSecureChannelEventType)
check_eventgenerator_SourceServer(self, evgen)
......@@ -561,22 +561,21 @@ class TestServerCaching(unittest.TestCase):
self.assertEqual(server.get_node(id).get_value(), 123)
os.remove(path)
class TestServerStartError(unittest.TestCase):
def test_port_in_use(self):
server1 = Server()
server1.set_endpoint('opc.tcp://localhost:{0:d}'.format(port_num + 1))
server1.set_endpoint('opc.tcp://127.0.0.1:{0:d}'.format(port_num + 1))
server1.start()
server2 = Server()
server2.set_endpoint('opc.tcp://localhost:{0:d}'.format(port_num + 1))
server2.set_endpoint('opc.tcp://127.0.0.1:{0:d}'.format(port_num + 1))
try:
server2.start()
except Exception:
pass
server1.stop()
server2.stop()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment