def test_connectionMgrComp(self): """ Tests that applications can make connections between their external ports """ self.launchDeviceManager('/nodes/test_PortTestDevice_node/DeviceManager.dcd.xml') app1 = self._rhDom.createApplication('/waveforms/PortConnectExternalPort/PortConnectExternalPort.sad.xml') app2 = self._rhDom.createApplication('/waveforms/PortConnectExternalPort/PortConnectExternalPort.sad.xml') for _comp in app1.comps: print 'searching: ',_comp.name, _comp._id if _comp._id[:50] == 'DCE:12ab27fb-01bd-4189-8d1d-0043b87c4f74:PortConne': break for _port in _comp.ports: if _port.name == 'resource_out': break self.assertEquals(len(_port._get_connections()), 0) ep1=rhconnection.makeEndPoint(_comp, 'resource_out') print ep1 ep2=rhconnection.makeEndPoint(app2, '') print ep2 cMgr = self._rhDom._get_connectionMgr() cMgr.connect(ep1,ep2) self.assertEquals(len(_port._get_connections()), 1)
def test_connectionMgrApp(self): """ Tests that applications can make connections between their external ports """ self.launchDeviceManager('/nodes/test_PortTestDevice_node/DeviceManager.dcd.xml') app1 = self._rhDom.createApplication('/waveforms/PortConnectExternalPort/PortConnectExternalPort.sad.xml') app2 = self._rhDom.createApplication('/waveforms/PortConnectExternalPort/PortConnectExternalPort.sad.xml') # Tally up the connections prior to making an app-to-app connection; # the PortTest component's runTest method returns the identifiers of # any connected Resources pre = [] for comp in app1.comps + app2.comps: pre.extend(comp.runTest(0, [])) ep1=rhconnection.makeEndPoint(app1, 'resource_out') ep2=rhconnection.makeEndPoint(app2, '') cMgr = self._rhDom._get_connectionMgr() cMgr.connect(ep1,ep2) # Tally up the connections to check that a new one has been made post = [] for comp in app1.comps + app2.comps: post.extend(comp.runTest(0, [])) self.assertTrue(len(post) > len(pre))
def test_connect_ServicesConnections(self): app_src = self.dom.createApplication( '/waveforms/svc_connect/svc_connect.sad.xml', 'svc_connect', [], []) nb, self._devMgrSvc = self.launchDeviceManager( '/nodes/test_BasicService_node/DeviceManager.dcd.xml') comp_src = app_src.comps[0] for svc in self.dom.services: if svc.name == 'BasicService1': break uses = rhconnection.makeEndPoint(comp_src, 'output') provides = rhconnection.makeEndPoint(svc, '') connectionReportId = self.cm.connect(uses, provides, 'test_environment', 'test_connection') connections = self.cm.connections self.assertEqual(len(connections), 2) connection = self._findConnection(connections, 'test_connection') self.assertFalse(connection is None) self.assertTrue(connection.connected) self.assertEqual(connection.usesEndpoint.portName, 'output') connections = connection.usesEndpoint.endpointObject._narrow( ExtendedCF.QueryablePort)._get_connections() out_connections = comp_src.ports[0].ref._get_connections() self.assertTrue(connections[0].port._is_equivalent( out_connections[0].port)) self.assertTrue(len(connections) == 1) self.assertEqual(connections[0].connectionId, 'test_connection')
def test_connect_ComponentConnections(self): app_src = self.dom.createApplication( '/waveforms/comp_src_w/comp_src_w.sad.xml', 'src_app', [], []) app_snk = self.dom.createApplication( '/waveforms/comp_snk_w/comp_snk_w.sad.xml', 'snk_app', [], []) comp_src = app_src.comps[0] comp_snk = app_snk.comps[0] uses = rhconnection.makeEndPoint(comp_src, 'output') provides = rhconnection.makeEndPoint(comp_snk, 'input') connectionReportId = self.cm.connect(uses, provides, 'test_environment', 'test_connection') connections = self.cm.connections self.assertEqual(len(connections), 2) connection = self._findConnection(connections, 'test_connection') self.assertFalse(connection is None) self.assertTrue(connection.connected) self.assertEqual(connection.usesEndpoint.portName, 'output') self.assertEqual(connection.providesEndpoint.portName, 'input') connections = connection.usesEndpoint.endpointObject._narrow( ExtendedCF.QueryablePort)._get_connections() out_connections = comp_src.ports[0].ref._get_connections() self.assertTrue(connections[0].port._is_equivalent( out_connections[0].port)) self.assertTrue(len(connections) == 1) self.assertEqual(connections[0].connectionId, 'test_connection')
def test_connect_DeviceConnections(self): # The DCD has one connection, verify that it is listed connections = self.cm.connections self.assertEqual(len(connections), 1) # Use the first device's resource_out port as the uses endpoint uses = rhconnection.makeEndPoint(self.dev2, 'resource_out') # Use the device itself as the provides endpoint provides = rhconnection.makeEndPoint(self.dev1, '') # Create a new connection with a known ID connectionReportId = self.cm.connect(uses, provides, 'test_environment', 'test_connection') # Make sure the new connection is listed connections = self.cm.connections self.assertEqual(len(connections), 2) connection = self._findConnection(connections, 'test_connection') self.assertFalse(connection is None) # get connnections list clist, citer = self.cm.listConnections() self.assertEqual(clist, []) conn = citer.next_one() self.assertEqual(conn.usesEndpoint.portName, 'resource_out') conn = citer.next_one() self.assertEqual(conn.usesEndpoint.portName, 'resource_out') conn = citer.next_one() self.assertEqual(conn, None) # The connection should have been resolved immediately self.assertTrue(connection.connected) self.assertEqual(connection.usesEndpoint.portName, 'resource_out') self.assertEqual(connection.providesEndpoint.portName, '') # Verify that the connection was really made connections = connection.usesEndpoint.endpointObject._get_connections() self.assertTrue(len(connections) == 1) self.assertEqual(connections[0].connectionId, 'test_connection') self.assertEqual(connections[0].port._get_identifier(), self.devId1) # Break the connection and make sure the connection went away self.cm.disconnect(connectionReportId) connections = self.cm.connections self.assertEqual(len(connections), 1)
def test_connect_ApplicationConnections(self): app = self.dom.createApplication( '/waveforms/PortConnectExternalPortRename/PortConnectExternalPortRename.sad.xml' ) # Connect the application's external uses port to the first device's # provides port uses = rhconnection.makeEndPoint(app, 'rename_resource_out') provides = rhconnection.makeEndPoint(self.dev1, 'resource_in') connectionReportId = self.cm.connect(uses, provides, 'test_environment', 'test_connection') # Make sure the new connection is listed connections = self.cm.connections self.assertEqual(len(connections), 2) connection = self._findConnection(connections, 'test_connection') self.assertFalse(connection is None) # The connection should have been resolved immediately self.assertTrue(connection.connected) self.assertEqual(connection.usesEndpoint.portName, 'rename_resource_out') self.assertEqual(connection.providesEndpoint.portName, 'resource_in') # Verify that the connection was really made connections = connection.usesEndpoint.endpointObject._get_connections() self.assertTrue(len(connections) == 1) self.assertEqual(connections[0].connectionId, 'test_connection') self.assertEqual(connections[0].port._get_identifier(), self.devId1 + '/resource_in') # Break the connection and make sure the connection went away self.cm.disconnect(connectionReportId) connections = self.cm.connections self.assertEqual(len(connections), 1) app.releaseObject()