def test_MultipleDevicesWithSameName(self):
        # Test that two different device managers can start devices with the same name

        # TODO We should check that these two actually have a device that has the same name
        # because, if someone changes the XML unwittingly then this test will pass
        # without really testing anything
        nb1, devMgr1 = self.launchDeviceManager(
            "/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml",
            debug=self.debuglevel)
        nb2, devMgr2 = self.launchDeviceManager(
            "/nodes/test_BasicTestDevice2_node/DeviceManager.dcd.xml",
            debug=self.debuglevel)

        self.assertEqual(len(self._domMgr._get_deviceManagers()), 2)
        for devMgr in self._domMgr._get_deviceManagers():
            self.assertEqual(len(devMgr._get_registeredDevices()), 1)

        # Although nothing in the spec specifies where a device is to be bound
        # ossie does /DomainName/DevicemgrName/DeviceName, so let's check that now
        # to ensure the behavior remains consistent
        dev1Name = URI.stringToName(scatest.getTestDomainName() +
                                    "/BasicTestDevice_node/BasicTestDevice1")
        dev2Name = URI.stringToName(scatest.getTestDomainName() +
                                    "/BasicTestDevice2_node/BasicTestDevice1")

        dev1 = self._root.resolve(dev1Name)._narrow(CF.Device)
        dev2 = self._root.resolve(dev2Name)._narrow(CF.Device)
        self.assertNotEqual(dev1, None)
        self.assertNotEqual(dev2, None)
    def _test_BasicService(self, node, expected_name):
        devmgr_nb, devMgr = self.launchDeviceManager("/nodes/" + node +
                                                     "/DeviceManager.dcd.xml",
                                                     debug=1)
        self.assertEqual(len(devMgr._get_registeredServices()), 1)
        svc = devMgr._get_registeredServices()[0]
        self.assertNotEqual(svc, None)
        self.assertEqual(svc.serviceName, expected_name)
        self.assertNotEqual(svc.serviceObject, None)
        obj = svc.serviceObject
        obj = obj._narrow(CF.PropertySet)
        self.assertNotEqual(obj, None)

        # Check the name service to ensure the service is properly bound
        svcName = URI.stringToName(scatest.getTestDomainName() + "/" +
                                   expected_name)
        svcobj = self._root.resolve(svcName)._narrow(CF.PropertySet)
        self.assertNotEqual(svcobj, None)
        self.assert_(obj._is_equivalent(svcobj))

        # Check that all the parameters got set correctly
        props = obj.query([])
        d = dict([(p.id, any.from_any(p.value)) for p in props])
        self.assertEqual(d["SERVICE_NAME"], expected_name)
        self.assertEqual(d["DEVICE_MGR_IOR"],
                         self._orb.object_to_string(devMgr))
        self.assertEqual(d["PARAM1"], "ABCD")
        self.assertEqual(d["PARAM2"], 42)
        self.assertAlmostEqual(d["PARAM3"], 3.1459)
        self.assertEqual(d["PARAM4"], False)
        self.assertEqual(d["PARAM5"], "Hello World")
        self.assertEqual(d.has_key("PARAM6"), False)

        # Check that we unregister correctly
        os.kill(devmgr_nb.pid, signal.SIGTERM)

        svcName = URI.stringToName(scatest.getTestDomainName() + "/" +
                                   expected_name)
        time_begin = time.time()
        time_end = time.time()
        name_found = True
        while ((time_end - time_begin) < 2) and name_found:
            time_end = time.time()
            # Don't use assertRaises, so we can simplify things
            try:
                self._root.resolve(svcName)._narrow(CF.PropertySet)
                time.sleep(0.1)
            except CosNaming.NamingContext.NotFound:
                name_found = False
        if name_found:
            self.fail("Expected service to not exist in the naming service")
Example #3
0
 def setUp(self):
     domBooter, self._domMgr = self.launchDomainManager()
     self._rhDom = redhawk.attach(scatest.getTestDomainName())
     self.basedir = '/tmp'
     self.data_signal = threading.Event()
     self.delete_feedback_signal = threading.Event()
     self.read_feedback_signal = threading.Event()
    def test_nodeBooterDomainNameOverride(self):
        """Test that we can allow the user to override the domainname with the --domainname argument."""
        domainName = scatest.getTestDomainName()
        domainMgrURI = URI.stringToName("%s/%s" % (domainName, domainName))
        # Test that we don't already have a bound domain
        try:
            domMgr = self._root.resolve(domainMgrURI)
            self.assertEqual(domMgr, None)
        except CosNaming.NamingContext.NotFound:
            pass # This exception is expected
        args = ["../../control/framework/nodeBooter","-D", "--domainname", domainName, "-debug", "9","--nopersist" ]
        nb = Popen(args, cwd=scatest.getSdrPath() )
        domMgr = self.waitDomainManager(domainMgrURI)
        self.assertNotEqual(domMgr, None)

        # Kill the nodebooter
        os.kill(nb.pid, signal.SIGINT)
        self.assertPredicateWithWait(lambda: nb.poll() == 0)

        # Test that we cleaned up the name; this should be automatic because
        # the naming context should be empty.
        try:
            domMgr = self._root.resolve(domainMgrURI)
            self.assertEqual(domMgr, None)
        except CosNaming.NamingContext.NotFound:
            pass # This exception is expected
    def test_EventDevicePortConnection(self):
        self.localEvent = threading.Event()
        self.eventFlag = False
        
        self._devBooter, self._devMgr = self.launchDeviceManager("/nodes/test_EventPortTestDevice_node/DeviceManager.dcd.xml", self._domMgr)
        time.sleep(1)   # this sleep is here for the connections to be established to the event service

        domainName = scatest.getTestDomainName()

        req = CF.EventChannelManager.EventRegistration( 'deviceEvent', '')
        try:
            ecm = self._domMgr._get_eventChannelMgr()
            creg = ecm.registerResource( req ) 
            devChannel = creg.channel
        except:
            self.assertEqual(False, True)
        else:
            self.assertEqual(True, True)

        # resolve the producer for the event
        supplier_admin = devChannel.for_suppliers()
        _proxy_consumer = supplier_admin.obtain_push_consumer()
        _supplier = Supplier_i()
        _proxy_consumer.connect_push_supplier(_supplier._this())

        # resolve the consumer for the event
        consumer_admin = devChannel.for_consumers()
        _proxy_supplier = consumer_admin.obtain_push_supplier()
        _consumer = ConsumerDevice_i(self)
        _proxy_supplier.connect_push_consumer(_consumer._this())

        _proxy_consumer.push(any.to_any("message device"))
        self.localEvent.wait(5.0)
        self.assertEqual(self.eventFlag, True)
    def test_nodeBooterDomainNameFromDMD(self):
        """Test that we read the correct domainname from the DMD file, the test domain
        should have been created by the test runner"""
        domainName = scatest.getTestDomainName()
        # Test that we don't already have a bound domain
        try:
            domMgr = self._root.resolve(scatest.getDomainMgrURI())
            self.assertEqual(domMgr, None)
        except CosNaming.NamingContext.NotFound:
            pass # This exception is expected

        args = ["../../control/framework/nodeBooter","-D","-debug", "9","--nopersist" ]
        nb = Popen( args, cwd=scatest.getSdrPath())
        domMgr = self.waitDomainManager(scatest.getDomainMgrURI())
        self.assertNotEqual(domMgr, None)

        # Kill the nodebooter
        os.kill(nb.pid, signal.SIGINT)
        self.assertPredicateWithWait(lambda: nb.poll() == 0)

        # Test that we cleaned up the name; this should be automatic because
        # the naming context should be empty.
        try:
            domMgr = self._root.resolve(scatest.getDomainMgrURI())
            self.assertEqual(domMgr, None)
        except CosNaming.NamingContext.NotFound:
            pass # This exception is expected
 def setUp(self):
     domBooter, self._domMgr = self.launchDomainManager()
     devBooter, self._devMgr = self.launchDeviceManager(
         "/nodes/test_ExecutableDevice_node/DeviceManager.dcd.xml")
     self._rhDom = redhawk.attach(scatest.getTestDomainName())
     self.app = self._rhDom.createApplication(
         "/waveforms/TestPythonProps/TestPythonProps.sad.xml")
    def test_EventAppPortConnection(self):
        self.localEvent = threading.Event()
        self.eventFlag = False
        
        self._devBooter, self._devMgr = self.launchDeviceManager("/nodes/test_EventPortTestDevice_node/DeviceManager.dcd.xml", self._domMgr, debug=self.debuglevel)
        domainName = scatest.getTestDomainName()
        self._domMgr.installApplication("/waveforms/PortConnectFindByDomainFinderEvent/PortConnectFindByDomainFinderEvent.sad.xml")
        appFact = self._domMgr._get_applicationFactories()[0]
        app = appFact.create(appFact._get_name(), [], [])
        app.start()
        channelName = URI.stringToName("%s/%s" % (domainName, 'anotherChannel'))
        try:
            appChannel = self._root.resolve(channelName)._narrow(CosEventChannelAdmin__POA.EventChannel)
        except:
            self.assertEqual(False, True)
        else:
            self.assertEqual(True, True)

        # resolve the producer for the event
        supplier_admin = appChannel.for_suppliers()
        _proxy_consumer = supplier_admin.obtain_push_consumer()
        _supplier = Supplier_i()
        _proxy_consumer.connect_push_supplier(_supplier._this())

        # resolve the consumer for the event
        consumer_admin = appChannel.for_consumers()
        _proxy_supplier = consumer_admin.obtain_push_supplier()
        _consumer = Consumer_i(self)
        _proxy_supplier.connect_push_consumer(_consumer._this())

        _proxy_consumer.push(any.to_any("message"))
        self.localEvent.wait(5.0)
        self.assertEqual(self.eventFlag, True)

        app.releaseObject()
    def test_EventDevicePortConnection(self):
        self.localEvent = threading.Event()
        self.eventFlag = False
        
        self._devBooter, self._devMgr = self.launchDeviceManager("/nodes/test_EventPortTestDevice_node/DeviceManager.dcd.xml", self._domMgr, debug=self.debuglevel)
        time.sleep(1)   # this sleep is here for the connections to be established to the event service

        domainName = scatest.getTestDomainName()

        channelName = URI.stringToName("%s/%s" % (domainName, 'deviceEvent'))
        try:
            devChannel = self._root.resolve(channelName)._narrow(CosEventChannelAdmin__POA.EventChannel)
        except:
            self.assertEqual(False, True)
        else:
            self.assertEqual(True, True)

        # resolve the producer for the event
        supplier_admin = devChannel.for_suppliers()
        _proxy_consumer = supplier_admin.obtain_push_consumer()
        _supplier = Supplier_i()
        _proxy_consumer.connect_push_supplier(_supplier._this())

        # resolve the consumer for the event
        consumer_admin = devChannel.for_consumers()
        _proxy_supplier = consumer_admin.obtain_push_supplier()
        _consumer = ConsumerDevice_i(self)
        _proxy_supplier.connect_push_consumer(_consumer._this())

        _proxy_consumer.push(any.to_any("message device"))
        self.localEvent.wait(5.0)
        self.assertEqual(self.eventFlag, True)
    def test_EventAppPortConnectionSIGINT(self):
        self.localEvent = threading.Event()
        self.eventFlag = False

        self._nb_domMgr, domMgr = self.launchDomainManager(
            endpoint="giop:tcp::5679", dbURI=self._dbfile)
        self._nb_devMgr, devMgr = self.launchDeviceManager(
            "/nodes/test_EventPortTestDevice_node/DeviceManager.dcd.xml")

        domainName = scatest.getTestDomainName()
        domMgr.installApplication(
            "/waveforms/PortConnectFindByDomainFinderEvent/PortConnectFindByDomainFinderEvent.sad.xml"
        )
        appFact = domMgr._get_applicationFactories()[0]
        app = appFact.create(appFact._get_name(), [], [])
        app.start()

        # Kill the domainMgr
        os.kill(self._nb_domMgr.pid, signal.SIGINT)
        if not self.waitTermination(self._nb_domMgr, 5.0):
            self.fail("Domain Manager Failed to Die")

        # Restart the Domain Manager (which should restore the old channel)
        self._nb_domMgr, domMgr = self.launchDomainManager(
            endpoint="giop:tcp::5679", dbURI=self._dbfile)

        newappFact = domMgr._get_applicationFactories()
        self.assertEqual(len(newappFact), 0)

        apps = domMgr._get_applications()
        self.assertEqual(len(apps), 0)

        devMgrs = domMgr._get_deviceManagers()
        self.assertEqual(len(devMgrs), 0)
    def test_DeviceManagerSurprise(self):
        self._nb_domMgr, self._domMgr = self.launchDomainManager(
            endpoint="giop:tcp::5679", dbURI=self._dbfile)
        self.assertEqual(len(self._domMgr._get_deviceManagers()), 0)

        # Kill the domainMgr
        os.kill(self._nb_domMgr.pid, signal.SIGKILL)
        if not self.waitTermination(self._nb_domMgr):
            self.fail("Domain Manager Failed to Die")

        self._nb_devMgr, devMgr = self.launchDeviceManager(
            "/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml",
            wait=False)
        # this sleep is needed to allow the Device Manager to figure out that the Domain Manager is not available
        time.sleep(1)

        # Start the domainMgr again
        self._nb_domMgr, newDomMgr = self.launchDomainManager(
            endpoint="giop:tcp::5679", dbURI=self._dbfile)
        time.sleep(
            1
        )  # sleep needed to make sure that the Device Manager has registered with the Domain Manager

        node_name = 'BasicTestDevice_node'
        domainName = scatest.getTestDomainName()
        devMgrURI = URI.stringToName("%s/%s/BasicTestDevice1" %
                                     (domainName, node_name))
        dev = self._root.resolve(devMgrURI)
        self.assertNotEqual(dev, None)

        self.assertEqual(len(self._domMgr._get_deviceManagers()), 1)
    def test_cpp_event_appender_create_channel(self):
        cfg = "log4j.rootLogger=ERROR,STDOUT,pse\n" + \
            "# Direct log messages to STDOUT \n" + \
            "log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender\n" + \
            "log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout\n" + \
            "log4j.appender.STDOUT.layout.ConversionPattern=@@@COMPONENT.NAME@@@\n" + \
            "# Direct log messages to event channel\n" + \
            "log4j.appender.pse=org.ossie.logging.RH_LogEventAppender\n" + \
            "log4j.appender.pse.name_context="+scatest.getTestDomainName()+"\n" + \
            "log4j.appender.pse.event_channel=TEST_EVT_CH1\n" + \
            "log4j.appender.pse.producer_id=PRODUCER1\n" + \
            "log4j.appender.pse.producer_name=THE BIG CHEESE\n" + \
            "log4j.appender.pse.layout=org.apache.log4j.PatternLayout\n" + \
            "log4j.appender.pse.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c:%L - %m%n\n"

        comp = self.app.comps[0]
        comp.ref.setLogConfig(cfg)
        comp.ref.start()
        comp.ref.stop()
        clist, citer = self._rhDom._get_eventChannelMgr().listChannels(5)
        reg_count = -1
        for _c in clist:
            if _c.channel_name == 'TEST_EVT_CH1':
                reg_count = _c.reg_count
        self.assertEquals(reg_count,
                          2)  # both the instance and static root loggers
        self.app.releaseObject()
        clist, citer = self._rhDom._get_eventChannelMgr().listChannels(5)
        reg_count = -1
        for _c in clist:
            if _c.channel_name == 'TEST_EVT_CH1':
                reg_count = _c.reg_count
        self.assertEquals(reg_count, 0)
    def test_EventAppPortConnectionSIGINT(self):
        self.localEvent = threading.Event()
        self.eventFlag = False

        self._nb_domMgr, domMgr = self.launchDomainManager(endpoint="giop:tcp::5679", dbURI=self._dbfile)
        self._nb_devMgr, devMgr = self.launchDeviceManager("/nodes/test_EventPortTestDevice_node/DeviceManager.dcd.xml")

        domainName = scatest.getTestDomainName()
        domMgr.installApplication("/waveforms/PortConnectFindByDomainFinderEvent/PortConnectFindByDomainFinderEvent.sad.xml")
        appFact = domMgr._get_applicationFactories()[0]
        app = appFact.create(appFact._get_name(), [], [])
        app.start()

        # Kill the domainMgr
        os.kill(self._nb_domMgr.pid, signal.SIGINT)
        if not self.waitTermination(self._nb_domMgr, 5.0):
            self.fail("Domain Manager Failed to Die")

        # Restart the Domain Manager (which should restore the old channel)
        self._nb_domMgr, domMgr = self.launchDomainManager(endpoint="giop:tcp::5679", dbURI=self._dbfile)

        newappFact = domMgr._get_applicationFactories()
        self.assertEqual(len(newappFact), 0)

        apps = domMgr._get_applications()
        self.assertEqual(len(apps), 0)

        devMgrs = domMgr._get_deviceManagers()
        self.assertEqual(len(devMgrs), 0)
 def setUp(self):
     domBooter, self._domMgr = self.launchDomainManager(
         loggingURI='file://' + os.getcwd() + '/macro_config.cfg')
     self.devBooter, self._devMgr = self.launchDeviceManager(
         "/nodes/test_ExecutableDevice_node/DeviceManager.dcd.xml",
         loggingURI='file://' + os.getcwd() + '/macro_config.cfg')
     self._rhDom = redhawk.attach(scatest.getTestDomainName())
 def setUp(self):
     domBooter, self._domMgr = self.launchDomainManager(
         debug=self.debuglevel)
     devBooter, self._devMgr = self.launchDeviceManager(
         "/nodes/test_ExecutableDevice_node/DeviceManager.dcd.xml",
         debug=self.debuglevel)
     self._rhDom = redhawk.attach(scatest.getTestDomainName())
     self.assertEquals(len(self._rhDom._get_applications()), 0)
    def _test_BasicService(self, node, expected_name):
        devmgr_nb, devMgr = self.launchDeviceManager("/nodes/"+node+"/DeviceManager.dcd.xml", debug=1)
        self.assertEqual(len(devMgr._get_registeredServices()), 1)
        svc = devMgr._get_registeredServices()[0]
        self.assertNotEqual(svc, None)
        self.assertEqual(svc.serviceName, expected_name)
        self.assertNotEqual(svc.serviceObject, None)
        obj = svc.serviceObject
        obj = obj._narrow(CF.PropertySet)
        self.assertNotEqual(obj, None)

        # Check the name service to ensure the service is properly bound
        svcName = URI.stringToName(scatest.getTestDomainName() + "/" + expected_name)
        svcobj = self._root.resolve(svcName)._narrow(CF.PropertySet)
        self.assertNotEqual(svcobj, None)
        self.assert_(obj._is_equivalent(svcobj))

        # Check that all the parameters got set correctly
        props = obj.query([])
        d = dict([(p.id, any.from_any(p.value)) for p in props])
        self.assertEqual(d["SERVICE_NAME"], expected_name)
        self.assertEqual(d["DEVICE_MGR_IOR"], self._orb.object_to_string(devMgr))
        self.assertEqual(d["PARAM1"], "ABCD")
        self.assertEqual(d["PARAM2"], 42)
        self.assertAlmostEqual(d["PARAM3"], 3.1459)
        self.assertEqual(d["PARAM4"], False)
        self.assertEqual(d["PARAM5"], "Hello World")
        self.assertEqual(d.has_key("PARAM6"), False)

        # Check that we unregister correctly
        os.kill(devmgr_nb.pid, signal.SIGTERM)

        svcName = URI.stringToName(scatest.getTestDomainName() + "/" + expected_name)
        time_begin = time.time()
        time_end = time.time()
        name_found = True
        while ((time_end - time_begin) < 2) and name_found:
            time_end = time.time()
            # Don't use assertRaises, so we can simplify things
            try:
                self._root.resolve(svcName)._narrow(CF.PropertySet)
                time.sleep(0.1)
            except CosNaming.NamingContext.NotFound:
                name_found = False
        if name_found:
            self.fail("Expected service to not exist in the naming service")
    def test_EventAppPortConnectionSIGQUIT(self):
        self.localEvent = threading.Event()
        self.eventFlag = False

        self._nb_domMgr, domMgr = self.launchDomainManager(endpoint="giop:tcp::5679", dbURI=self._dbfile)
        self._nb_devMgr, devMgr = self.launchDeviceManager("/nodes/test_EventPortTestDevice_node/DeviceManager.dcd.xml")

        domainName = scatest.getTestDomainName()
        domMgr.installApplication("/waveforms/PortConnectFindByDomainFinderEvent/PortConnectFindByDomainFinderEvent.sad.xml")
        appFact = domMgr._get_applicationFactories()[0]
        app = appFact.create(appFact._get_name(), [], [])
        app.start()

        # Kill the domainMgr
        os.kill(self._nb_domMgr.pid, signal.SIGQUIT)
        if not self.waitTermination(self._nb_domMgr, 5.0):
            self.fail("Domain Manager Failed to Die")

        # Restart the Domain Manager (which should restore the old channel)
        self._nb_domMgr, domMgr = self.launchDomainManager(endpoint="giop:tcp::5679", dbURI=self._dbfile)

        newappFact = domMgr._get_applicationFactories()[0]
        app2 = newappFact.create(appFact._get_name(), [], [])
        app2.start()
        channelName = URI.stringToName("%s/%s" % (domainName, 'anotherChannel'))
        try:
            appChannel = self._root.resolve(channelName)._narrow(CosEventChannelAdmin.EventChannel)
        except:
            self.assertEqual(False, True)
        else:
            self.assertEqual(True, True)

        # resolve the producer for the event
        supplier_admin = appChannel.for_suppliers()
        _proxy_consumer = supplier_admin.obtain_push_consumer()
        _supplier = Supplier_i()
        _proxy_consumer.connect_push_supplier(_supplier._this())

        # resolve the consumer for the event
        consumer_admin = appChannel.for_consumers()
        _proxy_supplier = consumer_admin.obtain_push_supplier()
        _consumer = Consumer_i(self)
        _proxy_supplier.connect_push_consumer(_consumer._this())

        # a flag is raised only when two responses come back (one for each running app)
        _proxy_consumer.push(any.to_any("message"))
        self.localEvent.wait(5.0)
        self.assertEqual(self.eventFlag, True)

        self.eventFlag = False
        # this step tests whether the number of subscribers to the channel is restored
        app2.releaseObject()

        self.localEvent.clear()
        _proxy_consumer.push(any.to_any("message"))
        self.localEvent.wait(5.0)
        self.assertEqual(self.eventFlag, True)
        app.releaseObject()
Example #18
0
    def test_PropertyChangeListener_EC_APP(self):
        self.localEvent = threading.Event()
        self.eventFlag = False

        self._devBooter, self._devMgr = self.launchDeviceManager(execDeviceNode, self._domMgr)
        self.assertNotEqual(self._devBooter, None)
        self._domMgr.installApplication("/waveforms/PropertyChangeListener/PropertyChangeListener.sad.xml")
        appFact = self._domMgr._get_applicationFactories()[0]
        self.assertNotEqual(appFact, None)
        app = appFact.create(appFact._get_name(), [], [])
        self.assertNotEqual(app, None)
        self._app = app

        ps=None
        c=None
        d=redhawk.attach(scatest.getTestDomainName())
        a=d.apps[0]
        # component with external property
        c=filter( lambda c : c.name == 'PropertyChange_C1', a.comps )[0]
        # assembly controller
        c2=filter( lambda c : c.name == 'PropertyChange_P1', a.comps )[0]
        self.assertNotEqual(a,None)
        self.assertNotEqual(c,None)
        self.assertNotEqual(c2,None)
        ps = a.ref._narrow(CF.PropertySet)
        self.assertNotEqual(ps,None)

        # check if channel is valid
        self.assertNotEqual(self.channel1, None)
        self.assertNotEqual(self.channel1._narrow(CosEventChannelAdmin.EventChannel), None)

        sub = Subscriber( self.channel1 )

        t=float(0.5)
        regid=ps.registerPropertyListener( self.channel1, ['prop1', 'app_prop1'],t)
        app.start()
        time.sleep(1)

        # assign 3 changed values
        c.prop1 = 100.0
        time.sleep(.6)   # wait for listener to receive notice
        c.prop1 = 200.0
        time.sleep(.6)   # wait for listener to receive notice
        c.prop1 = 300.0
        time.sleep(.6)   # wait for listener to receive notice

        for n in range(4):
            xx=sub.getData()
            self.assertNotEqual(xx, None)

        # unregister
        ps.unregisterPropertyListener( regid )

        self.assertRaises( CF.InvalidIdentifier,
            ps.unregisterPropertyListener, regid )

        app.releaseObject()
        self._app=None
 def setUp(self):
     super(LoggingConfigPropTests, self).setUp()
     domBooter, self._domMgr = self.launchDomainManager(
         loggingURI="dom/mgr/logging.properties")
     devBooter, self._devMgr = self.launchDeviceManager(
         "/nodes/loggingconfig/DeviceManager.dcd.xml",
         loggingURI="dev/mgr/logging.properties")
     self._rhDom = redhawk.attach(scatest.getTestDomainName())
     self.assertEquals(len(self._rhDom._get_applications()), 0)
 def setUp(self):
     domBooter, self._domMgr = self.launchDomainManager()
     devBooter, self._devMgr = self.launchDeviceManager("/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml")
     self._domain=redhawk.attach(scatest.getTestDomainName())
     self._app = None
     if self._domMgr:
         try:
             self._app = self._domain.createApplication('/waveforms/TestJavaProps/TestJavaReadOnly.sad.xml')
         except:
             pass
Example #21
0
    def test_InvalidCapacity_node(self):
        domBooter, self._domMgr = self.launchDomainManager()
        devBooter, self._devMgr = self.launchDeviceManager("/nodes/invalid_capacity/DeviceManager.dcd.xml.java")

        from ossie.utils import redhawk
        dom=redhawk.attach(scatest.getTestDomainName())
        dev=dom.devices[0]
        self.assertNotEquals(dev,None)
        b=[ CF.DataType(id='myulong', value=CORBA.Any(CORBA.TC_ulong,3))]
        self.assertRaises(CF.Device.InvalidCapacity, dev.allocateCapacity, b)
    def test_NicDeploymentPolicySocketUnlocked(self):
        nodebooter, domMgr = self.launchDomainManager()
        devBooter, devMgr = self.launchDeviceManager("/nodes/test_affinity_node_unlocked/DeviceManager.dcd.xml")

        # Ensure the expected device is available
        self.assertNotEqual(devMgr, None)
        # wait for all devices to register
        count=0
        for count in range(10):
            if len( devMgr._get_registeredDevices() ) < 2 :
                time.sleep(1)
            else:
                break

        rhdom= redhawk.attach(scatest.getTestDomainName())
        
        try:
            app=rhdom.createApplication('affinity_test3')

            if app != None:
                self.check_affinity( 'C1',  get_match("sock0sans0"), False )
                self.check_affinity( 'C2',  get_match("sock0sans0"), False )
                app.releaseObject()
                if ( maxcpus < 2):  time.sleep(2)
        except CF.ApplicationFactory.CreateApplicationError as e:
            if ( "busy" in e.msg ) == False:
              raise

        # run second application to make sure we are still working
        #rhdom= redhawk.attach(scatest.getTestDomainName())
        try:
            app=rhdom.createApplication('affinity_test1')

            if app: 
                self.check_affinity( 'C2', get_match("5") , False )
                app.releaseObject()
                if ( maxcpus < 2):  time.sleep(2)
        except CF.ApplicationFactory.CreateApplicationError as e:
            if ( "busy" in e.msg ) == False:
              raise

        try:
            app=rhdom.createApplication('affinity_test2')

            if app != None:
                self.check_affinity( 'C2', get_match("sock1"), False )
                if app: app.releaseObject()
        except CF.ApplicationFactory.CreateApplicationError as e:
            if ( "busy" in e.msg ) == False:
              raise

        
        devMgr.shutdown()

        self.assertEqual(len(domMgr._get_deviceManagers()), 0)
    def test_NicDeploymentPolicySocketUnlocked(self):
        nodebooter, domMgr = self.launchDomainManager()
        devBooter, devMgr = self.launchDeviceManager(
            "/nodes/test_affinity_node_unlocked/DeviceManager.dcd.xml")

        # Ensure the expected device is available
        self.assertNotEqual(devMgr, None)
        # wait for all devices to register
        count = 0
        for count in range(10):
            if len(devMgr._get_registeredDevices()) < 2:
                time.sleep(1)
            else:
                break

        rhdom = redhawk.attach(scatest.getTestDomainName())

        try:
            app = rhdom.createApplication('affinity_test3')

            if app != None:
                self.check_affinity('C1', get_match("sock0sans0"), False)
                self.check_affinity('C2', get_match("sock0sans0"), False)
                app.releaseObject()
                if (maxcpus < 2): time.sleep(2)
        except CF.ApplicationFactory.CreateApplicationError as e:
            if ("busy" in e.msg) == False:
                raise

        # run second application to make sure we are still working
        #rhdom= redhawk.attach(scatest.getTestDomainName())
        try:
            app = rhdom.createApplication('affinity_test1')

            if app:
                self.check_affinity('C2', get_match("5"), False)
                app.releaseObject()
                if (maxcpus < 2): time.sleep(2)
        except CF.ApplicationFactory.CreateApplicationError as e:
            if ("busy" in e.msg) == False:
                raise

        try:
            app = rhdom.createApplication('affinity_test2')

            if app != None:
                self.check_affinity('C2', get_match("sock1sans0"), False)
                if app: app.releaseObject()
        except CF.ApplicationFactory.CreateApplicationError as e:
            if ("busy" in e.msg) == False:
                raise

        devMgr.shutdown()

        self.assertEqual(len(domMgr._get_deviceManagers()), 0)
 def setUp(self):
     self._domBooter, self._domMgr = self.launchDomainManager()
     self.dom = redhawk.attach(scatest.getTestDomainName())
     # create listener interface
     self._app = None
     self.channel_name = "TestChan"
     self.chanMgr = self.dom._get_eventChannelMgr()
     try:
         self.channel1 = self.chanMgr.create(self.channel_name)
     except CF.EventChannelManager.ChannelAlreadyExists:
         self.channel1 = self.chanMgr.get(self.channel_name)
    def test_nodeBooterShutdown(self):
        """Test that nodeBooter correctly cleans up.
        In OSSIE 0.7.4, and possibly before, killing a nodebooter that was running
        a device manager would prevent you from restarting the devicemanager without
        first restarting the domainmanager.  Test that this condition is fixed"""
        #  It is important that these core pieces somewhat work for all the other tests to succeed
        args = ["../../control/framework/nodeBooter","-D","-debug", "9","--nopersist" ]
        nb1= Popen( args, cwd=scatest.getSdrPath())
        domainName = scatest.getTestDomainName()

        domMgr = self.waitDomainManager(scatest.getDomainMgrURI())
        self.assertNotEqual(domMgr, None)
        self.assertEqual(len(domMgr._get_deviceManagers()), 0)

        args = ["../../control/framework/nodeBooter","-d","/nodes/test_ExecutableDevice_node/DeviceManager.dcd.xml",
                "--domainname", domainName ]
        nb2 = Popen( args, cwd=scatest.getSdrPath())
        self.assertPredicateWithWait(lambda: len(domMgr._get_deviceManagers()) == 1)

        # Wait until the DeviceManager has finished launching its devices
        devMgr = domMgr._get_deviceManagers()[0]
        self.assertPredicateWithWait(lambda: len(devMgr._get_registeredDevices()) == 1)

        os.kill(nb2.pid, signal.SIGINT)
        self.assertPredicateWithWait(lambda: nb2.poll() != None)
        self.assertEqual(len(domMgr._get_deviceManagers()), 0)

        # Restart the device manager to prove that the shutdown was graceful.
        # In OSSIE 0.7.4 this would fail.
        args = ["../../control/framework/nodeBooter","-d","/nodes/test_ExecutableDevice_node/DeviceManager.dcd.xml",
                "--domainname", domainName ]
        nb3 = Popen(args,  cwd=scatest.getSdrPath())
        self.assertPredicateWithWait(lambda: len(domMgr._get_deviceManagers()) == 1)

        # Wait until the DeviceManager has finished launching its devices
        devMgr = domMgr._get_deviceManagers()[0]
        self.assertPredicateWithWait(lambda: len(devMgr._get_registeredDevices()) == 1)

        os.kill(nb3.pid, signal.SIGINT)
        self.assertPredicateWithWait(lambda: nb3.poll() != None)
        self.assertEqual(len(domMgr._get_deviceManagers()), 0)

        os.kill(nb1.pid, signal.SIGINT)
        self.assertPredicateWithWait(lambda: nb1.poll() != None)

        # Test that we cleaned up the name; this should be automatic because
        # the naming context should be empty.
        try:
            domMgr = self._root.resolve(scatest.getDomainMgrURI())
            self.assertEqual(domMgr, None)
        except CosNaming.NamingContext.NotFound:
            pass # This exception is expected
Example #26
0
    def test_deallocate_overage_node_java(self):
        domBooter, self._domMgr = self.launchDomainManager()
        devBooter, self._devMgr = self.launchDeviceManager("/nodes/invalid_capacity/DeviceManager.dcd.xml.overage.java")

        from ossie.utils import redhawk
        dom=redhawk.attach(scatest.getTestDomainName())
        d=dom.devices[0]
        self.assertNotEquals(d,None)
        res=d.allocateCapacity({'myulong': 3 } )
        self.assertEquals(res,True)

        a=[ CF.DataType(id='myulong', value=CORBA.Any(CORBA.TC_ulong,3)), CF.DataType(id='myulong', value=CORBA.Any(CORBA.TC_ulong,3))]
        self.assertRaises(CF.Device.InvalidCapacity,d.deallocateCapacity, a)
def launchDomain(number, root):
    domainName = scatest.getTestDomainName() + '_' + str(number)
    _domainBooter = scatest.spawnNodeBooter(dmdFile='', domainname=domainName)
    while _domainBooter.poll() == None:
        _domainManager = None
        try:
            _domainManager = root.resolve(URI.stringToName("%s/%s" % (domainName, domainName)))._narrow(CF.DomainManager)
        except:
            _domainManager = None
        if _domainManager:
            break
        time.sleep(0.1)
    return (_domainBooter, _domainManager)
    def test_MultipleDevicesWithSameName(self):
        # Test that two different device managers can start devices with the same name

        # TODO We should check that these two actually have a device that has the same name
        # because, if someone changes the XML unwittingly then this test will pass
        # without really testing anything
        nb1, devMgr1 = self.launchDeviceManager("/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml")
        nb2, devMgr2 = self.launchDeviceManager("/nodes/test_BasicTestDevice2_node/DeviceManager.dcd.xml")

        self.assertEqual(len(self._domMgr._get_deviceManagers()), 2)
        for devMgr in self._domMgr._get_deviceManagers():
            self.assertEqual(len(devMgr._get_registeredDevices()), 1)

        # Although nothing in the spec specifies where a device is to be bound
        # ossie does /DomainName/DevicemgrName/DeviceName, so let's check that now
        # to ensure the behavior remains consistent
        dev1Name = URI.stringToName(scatest.getTestDomainName() + "/BasicTestDevice_node/BasicTestDevice1")
        dev2Name = URI.stringToName(scatest.getTestDomainName() + "/BasicTestDevice2_node/BasicTestDevice1")

        dev1 = self._root.resolve(dev1Name)._narrow(CF.Device)
        dev2 = self._root.resolve(dev2Name)._narrow(CF.Device)
        self.assertNotEqual(dev1, None)
        self.assertNotEqual(dev2, None)
Example #29
0
def launchDomain(number, root):
    domainName = scatest.getTestDomainName() + '_' + str(number)
    _domainBooter = scatest.spawnNodeBooter(dmdFile='', domainname=domainName)
    while _domainBooter.poll() == None:
        _domainManager = None
        try:
            _domainManager = root.resolve(
                URI.stringToName("%s/%s" % (domainName, domainName)))._narrow(
                    CF.DomainManager)
        except:
            _domainManager = None
        if _domainManager:
            break
        time.sleep(0.1)
    return (_domainBooter, _domainManager)
def launchDomain(number, root):
    domainName = scatest.getTestDomainName() + '_' + str(number)
    _domainBooter = scatest.spawnNodeBooter(dmdFile='', domainname=domainName)
    while _domainBooter.poll() == None:
        _domainManager = None
        try:
            _domainManager = root.resolve(
                URI.stringToName("%s/%s" % (domainName, domainName)))._narrow(
                    CF.DomainManager)
        except _CORBA.BAD_INV_ORDER:
            orb = _CORBA.ORB_init(_sys.argv, _CORBA.ORB_ID)
            ns = orb.resolve_initial_references("NameService")
            root = ns._narrow(CosNaming.NamingContext)
        except Exception, e:
            _domainManager = None
        if _domainManager:
            break
        time.sleep(0.1)
    def test_Property_JAVA(self):
        self._devBooter, self._devMgr = self.launchDeviceManager(
            "/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml",
            self._domMgr)
        self.assertNotEqual(self._devBooter, None)
        self._domMgr.installApplication(
            "/waveforms/Property_T2/Property_T2.sad.xml")
        appFact = self._domMgr._get_applicationFactories()[0]
        self.assertNotEqual(appFact, None)
        app = appFact.create(appFact._get_name(), [], [])
        self.assertNotEqual(app, None)
        app.start()
        time.sleep(1)

        ps = None
        c = None
        d = redhawk.attach(scatest.getTestDomainName())
        a = d.apps[0]
        c = filter(lambda c: c.name == 'Property_JAVA', a.comps)[0]
        self.assertNotEqual(c, None)
        ps = c.ref._narrow(CF.PropertySet)
        self.assertNotEqual(ps, None)

        self.assertEquals(c.p1, "prop1")
        self.assertAlmostEquals(c.p2, 123.4)
        self.assertEquals(c.p3, 567)
        self.assertEquals(c.p4.p4sub1, "prop2")
        t1 = int(c.p4.p4sub2)
        self.assertEquals(t1, 890)

        c.p1 = "testing"
        c.p2 = 100.0
        c.p3 = 100
        c.p4.p4sub1 = "testing2"
        c.p4.p4sub2 = 200.0

        self.assertEquals(c.p1, "testing")
        self.assertAlmostEquals(c.p2, 100.0)
        self.assertEquals(c.p3, 100)
        self.assertEquals(c.p4.p4sub1, "testing2")
        t1 = int(c.p4.p4sub2)
        self.assertEquals(t1, 200)

        app.releaseObject()
Example #32
0
    def test_EventAppPortConnection(self):
        self.localEvent = threading.Event()
        self.eventFlag = False

        self._devBooter, self._devMgr = self.launchDeviceManager(
            "/nodes/test_EventPortTestDevice_node/DeviceManager.dcd.xml",
            self._domMgr)
        domainName = scatest.getTestDomainName()
        self._domMgr.installApplication(
            "/waveforms/PortConnectFindByDomainFinderEvent/PortConnectFindByDomainFinderEvent.sad.xml"
        )
        appFact = self._domMgr._get_applicationFactories()[0]
        app = appFact.create(appFact._get_name(), [], [])
        app.start()

        # rh 1.11 and forward event channels belong to the Domain...
        req = CF.EventChannelManager.EventRegistration('anotherChannel', '')
        try:
            ecm = self._domMgr._get_eventChannelMgr()
            creg = ecm.registerResource(req)
            appChannel = creg.channel
        except:
            self.assertEqual(False, True)
        else:
            self.assertEqual(True, True)

        # resolve the producer for the event
        supplier_admin = appChannel.for_suppliers()
        _proxy_consumer = supplier_admin.obtain_push_consumer()
        _supplier = Supplier_i()
        _proxy_consumer.connect_push_supplier(_supplier._this())

        # resolve the consumer for the event
        consumer_admin = appChannel.for_consumers()
        _proxy_supplier = consumer_admin.obtain_push_supplier()
        _consumer = Consumer_i(self)
        _proxy_supplier.connect_push_consumer(_consumer._this())

        _proxy_consumer.push(any.to_any("message"))
        self.localEvent.wait(5.0)
        self.assertEqual(self.eventFlag, True)

        app.releaseObject()
    def test_Property_CPP(self):
        self._devBooter, self._devMgr = self.launchDeviceManager("/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml", self._domMgr)
        self.assertNotEqual(self._devBooter, None)
        self._domMgr.installApplication("/waveforms/Property_T1/Property_T1.sad.xml")
        appFact = self._domMgr._get_applicationFactories()[0]
        self.assertNotEqual(appFact, None)
        app = appFact.create(appFact._get_name(), [], [])
        self.assertNotEqual(app, None)
        app.start()
        time.sleep(1)

        ps=None
        c=None
        d=redhawk.attach(scatest.getTestDomainName())
        a=d.apps[0]
        c=filter( lambda c : c.name == 'Property_CPP', a.comps )[0]
        self.assertNotEqual(c,None)
        ps = c.ref._narrow(CF.PropertySet)
        self.assertNotEqual(ps,None)
        
        self.assertEquals(c.p1,"prop1")
        self.assertAlmostEquals(c.p2,123.4)
        self.assertEquals(c.p3,567)
        self.assertEquals(c.p4.p4sub1,"prop2")
        t1=int(c.p4.p4sub2)
        self.assertEquals(t1,890)

        c.p1 = "testing"
        c.p2 = 100.0
        c.p3 = 100
        c.p4.p4sub1="testing2"
        c.p4.p4sub2=200.0

        self.assertEquals(c.p1,"testing")
        self.assertAlmostEquals(c.p2,100.0)
        self.assertEquals(c.p3,100)
        self.assertEquals(c.p4.p4sub1,"testing2")
        t1=int(c.p4.p4sub2)
        self.assertEquals(t1,200)


        app.releaseObject()
Example #34
0
    def test_EventAppPortConnection(self):
        self.localEvent = threading.Event()
        self.eventFlag = False

        self._devBooter, self._devMgr = self.launchDeviceManager(
            "/nodes/test_EventPortTestDevice_node/DeviceManager.dcd.xml",
            self._domMgr,
            debug=self.debuglevel)
        domainName = scatest.getTestDomainName()
        self._domMgr.installApplication(
            "/waveforms/PortConnectFindByDomainFinderEvent/PortConnectFindByDomainFinderEvent.sad.xml"
        )
        appFact = self._domMgr._get_applicationFactories()[0]
        app = appFact.create(appFact._get_name(), [], [])
        app.start()
        channelName = URI.stringToName("%s/%s" %
                                       (domainName, 'anotherChannel'))
        try:
            appChannel = self._root.resolve(channelName)._narrow(
                CosEventChannelAdmin__POA.EventChannel)
        except:
            self.assertEqual(False, True)
        else:
            self.assertEqual(True, True)

        # resolve the producer for the event
        supplier_admin = appChannel.for_suppliers()
        _proxy_consumer = supplier_admin.obtain_push_consumer()
        _supplier = Supplier_i()
        _proxy_consumer.connect_push_supplier(_supplier._this())

        # resolve the consumer for the event
        consumer_admin = appChannel.for_consumers()
        _proxy_supplier = consumer_admin.obtain_push_supplier()
        _consumer = Consumer_i(self)
        _proxy_supplier.connect_push_consumer(_consumer._this())

        _proxy_consumer.push(any.to_any("message"))
        self.localEvent.wait(5.0)
        self.assertEqual(self.eventFlag, True)

        app.releaseObject()
Example #35
0
 def test_DelegateSBExternalProps(self):
     dom = redhawk.attach(scatest.getTestDomainName())
     app = dom.createApplication(
         "/waveforms/TestAppPropDelegate/TestAppPropDelegate.sad.xml")
     self.assertNotEqual(app, None)
     foo10 = None
     foo1 = None
     if app.comps[0].instanceName == 'foo10':
         foo10 = app.comps[0]
     elif app.comps[1].instanceName == 'foo10':
         foo10 = app.comps[1]
     if app.comps[0].instanceName == 'foo1':
         foo1 = app.comps[0]
     elif app.comps[1].instanceName == 'foo1':
         foo1 = app.comps[1]
     self.assertNotEqual(foo10, None)
     self.assertNotEqual(foo1, None)
     self.assertEquals(foo1.test_float, app.sometest)
     app.sometest = foo10.test_float * 10
     self.assertEquals(foo1.test_float, foo10.test_float * 10)
     self.assertEquals(foo1.test_float, app.sometest)
 def test_registerWithEventChannel_creation(self):
     # launch DomainManager
     nodebooter, self._domMgr = self.launchDomainManager()
     self.assertNotEqual(self._domMgr, None)
     self.gotData = False
     # set up consumer
     _consumer = Consumer_i(self)
     channelName = 'testChannel'
     self._domMgr.registerWithEventChannel(_consumer._this(), 'some_id', channelName)
     domainName = scatest.getTestDomainName()
     eventChannelURI = URI.stringToName("%s/%s" % (domainName, channelName))
     channel = self._root.resolve(eventChannelURI)._narrow(CosEventChannelAdmin.EventChannel)
     supplier_admin = channel.for_suppliers()
     proxy_consumer = supplier_admin.obtain_push_consumer()
     proxy_consumer.connect_push_supplier(None)
     proxy_consumer.push(any.to_any(True))
     begin_time = time.time()
     timeout = 5 # maximum of 5 seconds
     while ((time.time() - begin_time) < timeout) and not self.gotData:
         time.sleep(0.1)
     self.assertEqual(self.gotData, True)
     self._domMgr.unregisterFromEventChannel('some_id', channelName)
    def test_EventAppPortConnection(self):
        self.localEvent = threading.Event()
        self.eventFlag = False
        
        self._devBooter, self._devMgr = self.launchDeviceManager("/nodes/test_EventPortTestDevice_node/DeviceManager.dcd.xml", self._domMgr)
        domainName = scatest.getTestDomainName()
        self._domMgr.installApplication("/waveforms/PortConnectFindByDomainFinderEvent/PortConnectFindByDomainFinderEvent.sad.xml")
        appFact = self._domMgr._get_applicationFactories()[0]
        app = appFact.create(appFact._get_name(), [], [])
        app.start()

        # rh 1.11 and forward event channels belong to the Domain...
        req = CF.EventChannelManager.EventRegistration( 'anotherChannel', '')
        try:
            ecm = self._domMgr._get_eventChannelMgr()
            creg = ecm.registerResource( req ) 
            appChannel = creg.channel
        except:
            self.assertEqual(False, True)
        else:
            self.assertEqual(True, True)

        # resolve the producer for the event
        supplier_admin = appChannel.for_suppliers()
        _proxy_consumer = supplier_admin.obtain_push_consumer()
        _supplier = Supplier_i()
        _proxy_consumer.connect_push_supplier(_supplier._this())

        # resolve the consumer for the event
        consumer_admin = appChannel.for_consumers()
        _proxy_supplier = consumer_admin.obtain_push_supplier()
        _consumer = Consumer_i(self)
        _proxy_supplier.connect_push_consumer(_consumer._this())

        _proxy_consumer.push(any.to_any("message"))
        self.localEvent.wait(5.0)
        self.assertEqual(self.eventFlag, True)

        app.releaseObject()
 def test_registerWithEventChannel_creation(self):
     # launch DomainManager
     nodebooter, self._domMgr = self.launchDomainManager()
     self.assertNotEqual(self._domMgr, None)
     self.gotData = False
     # set up consumer
     _consumer = Consumer_i(self)
     channelName = 'testChannel'
     self._domMgr.registerWithEventChannel(_consumer._this(), 'some_id', channelName)
     domainName = scatest.getTestDomainName()
     eventChannelURI = URI.stringToName("%s/%s" % (domainName, channelName))
     channel = self._root.resolve(eventChannelURI)._narrow(CosEventChannelAdmin.EventChannel)
     supplier_admin = channel.for_suppliers()
     proxy_consumer = supplier_admin.obtain_push_consumer()
     proxy_consumer.connect_push_supplier(None)
     proxy_consumer.push(any.to_any(True))
     begin_time = time.time()
     timeout = 5 # maximum of 5 seconds
     while ((time.time() - begin_time) < timeout) and not self.gotData:
         time.sleep(0.1)
     self.assertEqual(self.gotData, True)
     self._domMgr.unregisterFromEventChannel('some_id', channelName)
Example #39
0
    def test_EventDevicePortConnection(self):
        self.localEvent = threading.Event()
        self.eventFlag = False

        self._devBooter, self._devMgr = self.launchDeviceManager(
            "/nodes/test_EventPortTestDevice_node/DeviceManager.dcd.xml",
            self._domMgr)
        time.sleep(
            1
        )  # this sleep is here for the connections to be established to the event service

        domainName = scatest.getTestDomainName()

        req = CF.EventChannelManager.EventRegistration('deviceEvent', '')
        try:
            ecm = self._domMgr._get_eventChannelMgr()
            creg = ecm.registerResource(req)
            devChannel = creg.channel
        except:
            self.assertEqual(False, True)
        else:
            self.assertEqual(True, True)

        # resolve the producer for the event
        supplier_admin = devChannel.for_suppliers()
        _proxy_consumer = supplier_admin.obtain_push_consumer()
        _supplier = Supplier_i()
        _proxy_consumer.connect_push_supplier(_supplier._this())

        # resolve the consumer for the event
        consumer_admin = devChannel.for_consumers()
        _proxy_supplier = consumer_admin.obtain_push_supplier()
        _consumer = ConsumerDevice_i(self)
        _proxy_supplier.connect_push_consumer(_consumer._this())

        _proxy_consumer.push(any.to_any("message device"))
        self.localEvent.wait(5.0)
        self.assertEqual(self.eventFlag, True)
Example #40
0
    def test_EventDevicePortConnection(self):
        self.localEvent = threading.Event()
        self.eventFlag = False

        self._devBooter, self._devMgr = self.launchDeviceManager(
            "/nodes/test_EventPortTestDevice_node/DeviceManager.dcd.xml",
            self._domMgr,
            debug=self.debuglevel)
        time.sleep(
            1
        )  # this sleep is here for the connections to be established to the event service

        domainName = scatest.getTestDomainName()

        channelName = URI.stringToName("%s/%s" % (domainName, 'deviceEvent'))
        try:
            devChannel = self._root.resolve(channelName)._narrow(
                CosEventChannelAdmin__POA.EventChannel)
        except:
            self.assertEqual(False, True)
        else:
            self.assertEqual(True, True)

        # resolve the producer for the event
        supplier_admin = devChannel.for_suppliers()
        _proxy_consumer = supplier_admin.obtain_push_consumer()
        _supplier = Supplier_i()
        _proxy_consumer.connect_push_supplier(_supplier._this())

        # resolve the consumer for the event
        consumer_admin = devChannel.for_consumers()
        _proxy_supplier = consumer_admin.obtain_push_supplier()
        _consumer = ConsumerDevice_i(self)
        _proxy_supplier.connect_push_consumer(_consumer._this())

        _proxy_consumer.push(any.to_any("message device"))
        self.localEvent.wait(5.0)
        self.assertEqual(self.eventFlag, True)
Example #41
0
 def test_DelegateExternalProps(self):
     dom = redhawk.attach(scatest.getTestDomainName())
     app = dom.createApplication(
         "/waveforms/TestAppPropDelegate/TestAppPropDelegate.sad.xml")
     self.assertNotEqual(app, None)
     foo10 = None
     foo1 = None
     if app.comps[0].instanceName == 'foo10':
         foo10 = app.comps[0]
     elif app.comps[1].instanceName == 'foo10':
         foo10 = app.comps[1]
     if app.comps[0].instanceName == 'foo1':
         foo1 = app.comps[0]
     elif app.comps[1].instanceName == 'foo1':
         foo1 = app.comps[1]
     self.assertNotEqual(foo10, None)
     self.assertNotEqual(foo1, None)
     self.assertEquals(foo1.test_float, app.sometest)
     prop = CF.DataType(id='sometest',
                        value=any.to_any(foo10.test_float * 10))
     app.ref.configure([prop])
     self.assertEquals(foo1.test_float, foo10.test_float * 10)
     self.assertEquals(foo1.test_float, app.sometest)
 def setUp(self):
     domBooter, self._domMgr = self.launchDomainManager(debug=self.debuglevel)
     devBooter, self._devMgr = self.launchDeviceManager("/nodes/test_ExecutableDevice_node/DeviceManager.dcd.xml", debug=self.debuglevel)
     self._rhDom = redhawk.attach(scatest.getTestDomainName())
     self.assertEquals(len(self._rhDom._get_applications()), 0)
    def test_ServiceShutdown_DomMgr(self):
        num_services = 5
        num_devices = 1
        # This test makes sure that services are unregistered from the naming service upon shutdown of the DomainManager
        devmgr_nb, devMgr = self.launchDeviceManager("/nodes/test_MultipleService_node/DeviceManager.dcd.xml")
        timeout = 5
        begin_time = time.time()
        done = False
        while not done:
            current_time = time.time()
            if (current_time - begin_time) > timeout:
                break
            if len(devMgr._get_registeredServices()) == num_services:
                break
        self.assertEqual(len(devMgr._get_registeredServices()), num_services)

        # Makes sure that the correct number of processes forked
        self.assertEquals(len(getChildren(devmgr_nb.pid)), num_services + num_devices)

        svcName = URI.stringToName(scatest.getTestDomainName() + "/BasicService1")
        self._root.resolve(svcName)._narrow(CF.PropertySet)

        names = ["BasicService1", "BasicService2", "BasicService3", "BasicService4", "BasicService5"]

        for svc in devMgr._get_registeredServices():
            self.assertNotEqual(svc, None)
            self.assertEqual(svc.serviceName in names, True)
            names.remove(svc.serviceName)
            obj = svc.serviceObject
            obj = obj._narrow(CF.PropertySet)
            self.assertNotEqual(obj, None)

            # Check the name service to ensure the service is properly bound
            svcName = URI.stringToName(scatest.getTestDomainName() + "/" + svc.serviceName)
            svcobj = self._root.resolve(svcName)._narrow(CF.PropertySet)
            self.assertNotEqual(svcobj, None)
            self.assert_(obj._is_equivalent(svcobj))

            # Check that all the parameters got set correctly
            props = obj.query([])
            d = dict([(p.id, any.from_any(p.value)) for p in props])
            self.assertEqual(d["SERVICE_NAME"], svc.serviceName)
            self.assertEqual(d["DEVICE_MGR_IOR"], self._orb.object_to_string(devMgr))
            self.assertEqual(d["PARAM1"], "ABCD")
            self.assertEqual(d["PARAM2"], 42)
            self.assertEqual(d["PARAM3"], 3.1459)
            self.assertEqual(d["PARAM4"], False)
            self.assertEqual(d["PARAM5"], "Hello World")
            self.assertEqual(d.has_key("PARAM6"), False)

        # Check that we unregister correctly
        os.kill(self._domBooter.pid, signal.SIGINT)

        names = ["BasicService1", "BasicService2", "BasicService3", "BasicService4", "BasicService5"]
        svcNames = []
        for n in names:
            svcNames.append(URI.stringToName(scatest.getTestDomainName() + "/" + n))

        # Needs to allow time for unregistering
        self.assert_(self.waitTermination(self._domBooter), "Nodebooter did not die after shutdown")

        # Don't use assertRaises, so we can simplify things
        for name in svcNames:
            try:
                self._root.resolve(name)._narrow(CF.PropertySet)
            except CosNaming.NamingContext.NotFound:
                pass
            else:
                self.fail("Expected service to not exist in the naming service: " + str(name))

        # Makes sure that all children are dead
        self.assertEquals(len(getChildren(devmgr_nb.pid)), 0)
    def test_ExternalServices(self):
        devmgr_nb, devMgr = self.launchDeviceManager("/nodes/test_MultipleService_node/DeviceManager.dcd.xml")
        import ossie.utils.popen as _popen

        serviceName = "BasicService10"

        args = []
        args.append("sdr/dev/services/BasicService/BasicService.py")
        args.append("DEVICE_MGR_IOR")
        args.append(self._orb.object_to_string(devMgr))
        args.append("SERVICE_NAME")
        args.append(serviceName)
        args.append("LOGGING_CONFIG_URI")
        args.append("runtest.props")
        args.append("PARAM1")
        args.append("ABCD")
        args.append("PARAM2")
        args.append("42")
        args.append("PARAM3")
        args.append("3.1459")
        args.append("PARAM4")
        args.append("False")
        args.append("PARAM5")
        args.append("Hello World")
        exec_file = "sdr/dev/services/BasicService/BasicService.py"
        external_process = _popen.Popen(args, executable=exec_file, cwd=os.getcwd(), preexec_fn=os.setpgrp)

        serviceName2 = "BasicService11"
        args[4] = serviceName2
        exec_file = "sdr/dev/services/BasicService/BasicService.py"
        external_process2 = _popen.Popen(args, executable=exec_file, cwd=os.getcwd(), preexec_fn=os.setpgrp)

        time.sleep(1)

        names = ["BasicService1", "BasicService2", "BasicService3", "BasicService4", "BasicService5", serviceName, serviceName2]

        # Makes sure external service registered
        for svc in devMgr._get_registeredServices():
            self.assertNotEqual(svc, None)
            self.assertEqual(svc.serviceName in names, True)

            names.remove(svc.serviceName)
            obj = svc.serviceObject
            obj = obj._narrow(CF.PropertySet)
            self.assertNotEqual(obj, None)

            # Check the name service to ensure the service is properly bound
            svcName = URI.stringToName(scatest.getTestDomainName() + "/" + svc.serviceName)
            svcobj = self._root.resolve(svcName)._narrow(CF.PropertySet)
            self.assertNotEqual(svcobj, None)
            self.assert_(obj._is_equivalent(svcobj))

            # Check that all the parameters got set correctly
            props = obj.query([])
            d = dict([(p.id, any.from_any(p.value)) for p in props])
            self.assertEqual(d["SERVICE_NAME"], svc.serviceName)
            self.assertEqual(d["DEVICE_MGR_IOR"], self._orb.object_to_string(devMgr))
            self.assertEqual(d["PARAM1"], "ABCD")
            self.assertEqual(d["PARAM2"], 42)
            self.assertEqual(d["PARAM3"], 3.1459)
            self.assertEqual(d["PARAM4"], False)
            self.assertEqual(d["PARAM5"], "Hello World")
            self.assertEqual(d.has_key("PARAM6"), False)

        # Make sure a component can communicate with the Service
        self._domMgr.installApplication("/waveforms/ServiceConnection/ServiceConnection.sad.xml")
        self.assertEquals(len(self._domMgr._get_applicationFactories()), 1)
        factory = self._domMgr._get_applicationFactories()[0]
        app = factory.create(factory._get_name(), [], [])
        self.assertEquals(len(self._domMgr._get_applications()), 1)

        # Make sure an app that uses external services can launch
        app.start()
        port = app._get_registeredComponents()[0].componentObject.getPort("output")
        app.releaseObject()

        # Kill the 2 external services
        os.kill(external_process.pid, signal.SIGINT)
        os.kill(external_process2.pid, signal.SIGINT)

        # Give time for kill signals to be caught
        time.sleep(1)
        os.kill(devmgr_nb.pid, signal.SIGINT)

        # Make sure services are no longer register with the domain manager
        names = ["BasicService1", "BasicService2", "BasicService3", "BasicService4", "BasicService5", serviceName, serviceName2]
        svcNames = []
        for n in names:
            svcNames.append(URI.stringToName(scatest.getTestDomainName() + "/" + n))

        # Needs to allow time for unregistering
        self.assert_(self.waitTermination(devmgr_nb), "Nodebooter did not die after shutdown")

        # Don't use assertRaises, so we can simplify things
        for name in svcNames:
            try:
                self._root.resolve(name)._narrow(CF.PropertySet)
            except CosNaming.NamingContext.NotFound:
                pass
            else:
                self.fail("Expected service to not exist in the naming service")

        # Makes sure all children are cleaned
        self.assertEquals(len(getChildren(devmgr_nb.pid)), 0)
    def test_PropertyChangeListener_CPP(self):
        self.localEvent = threading.Event()
        self.eventFlag = False

        self._devBooter, self._devMgr = self.launchDeviceManager("/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml", self._domMgr)
        self.assertNotEqual(self._devBooter, None)
        if java_support:
            self._domMgr.installApplication("/waveforms/PropertyChangeListener/PropertyChangeListener.sad.xml")
        else:
            self._domMgr.installApplication("/waveforms/PropertyChangeListenerNoJava/PropertyChangeListenerNoJava.sad.xml")
        appFact = self._domMgr._get_applicationFactories()[0]
        self.assertNotEqual(appFact, None)
        app = appFact.create(appFact._get_name(), [], [])
        self.assertNotEqual(app, None)

        ps=None
        c=None
        d=redhawk.attach(scatest.getTestDomainName())
        a=d.apps[0]
        c=filter( lambda c : c.name == 'PropertyChange_C1', a.comps )[0]
        self.assertNotEqual(c,None)
        ps = c.ref._narrow(CF.PropertySet)
        self.assertNotEqual(ps,None)
        
        # create listener interface
        myl = PropertyChangeListener_Receiver()
        t=float(0.5)
        regid=ps.registerPropertyListener( myl._this(), ['prop1'],t)
        app.start()
        time.sleep(1)


        # assign 3 changed values
        c.prop1 = 100.0
        time.sleep(.6)   # wait for listener to receive notice
        c.prop1 = 200.0
        time.sleep(.6)   # wait for listener to receive notice
        c.prop1 = 300.0
        time.sleep(.6)   # wait for listener to receive notice
        
        # now check results
        self.assertEquals(myl.count,4)

        # change unmonitored property
        c.prop2 = 100
        time.sleep(.6)   # wait for listener to receive notice

        # now check results
        self.assertEquals(myl.count,4)

        # unregister
        ps.unregisterPropertyListener( regid )

        c.prop1 = 100.0
        time.sleep(.6)   # wait for listener to receive notice
        
        # now check results, should be same... 
        self.assertEquals(myl.count,4)

        self.assertRaises( CF.InvalidIdentifier,
            ps.unregisterPropertyListener, regid )
                           

        app.releaseObject()
 def setUp(self):
     self._domBooter, self._domMgr = self.launchDomainManager()
     self.dom = redhawk.attach(scatest.getTestDomainName())
     self.count = 0
    def test_ODMEvents_DeviceManager(self):
        # Test DeviceManager related events

        # launch DomainManager
        nodebooter, self._domMgr = self.launchDomainManager(debug=self.debuglevel)

        # connect to the channel
        domainName = scatest.getTestDomainName()
        channelManager = ChannelManager(self._orb)
        odmChannel = channelManager.getEventChannel('ODM_Channel', domainName)
        if odmChannel == None:
            self.fail("Could not connect to the ODM_Channel")


        # set up consumer
        consumer_admin = odmChannel.for_consumers()
        _proxy_supplier = consumer_admin.obtain_push_supplier()
        _consumer = ConsumerODM_i(self)
        _proxy_supplier.connect_push_consumer(_consumer._this())

        # start the device manager
        devBooter, devMgr = self.launchDeviceManager("/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml", debug=self.debuglevel)
        self.assertNotEqual(devMgr, None)

        timeout = 0.0
        while ((_consumer.getAddedEventCount('DEVICE_MANAGER') < 1 or _consumer.getAddedEventCount('DEVICE') < 1) and timeout < 2):
            timeout += 0.2
            time.sleep(0.2)

        try:
            devMgr.shutdown()
        except CORBA.Exception:
            pass

        timeout = 0.0
        while ((_consumer.getRemovedEventCount('DEVICE_MANAGER') < 1 or _consumer.getRemovedEventCount('DEVICE') < 1) and timeout < 2):
            timeout += 0.2
            time.sleep(0.2)

        # start the second device manager
        devBooter, devMgr = self.launchDeviceManager("/nodes/test_BasicService_node/DeviceManager.dcd.xml", debug=self.debuglevel)
        self.assertNotEqual(devMgr, None)

        timeout = 0.0
        while ((_consumer.getAddedEventCount('DEVICE_MANAGER') < 2 or _consumer.getAddedEventCount('SERVICE') < 1) and timeout < 2):
            timeout += 0.2
            time.sleep(0.2)

        try:
            devMgr.shutdown()
        except CORBA.Exception:
            pass

        timeout = 0.0
        while ((_consumer.getRemovedEventCount('DEVICE_MANAGER') < 2 or _consumer.getRemovedEventCount('SERVICE') < 1) and timeout < 2):
            timeout += 0.2
            time.sleep(0.2)


        self.assertEqual(_consumer.getAddedEventCount('DEVICE_MANAGER'), 2)
        self.assertEqual(_consumer.getAddedEventCount('DEVICE'), 1)
        self.assertEqual(_consumer.getAddedEventCount('SERVICE'), 1)
        self.assertEqual(_consumer.getRemovedEventCount('DEVICE_MANAGER'), 2)
        self.assertEqual(_consumer.getRemovedEventCount('DEVICE'), 1)
        self.assertEqual(_consumer.getRemovedEventCount('SERVICE'), 1)

        self.terminateChild(devBooter)