def tearDown(self):
        self.comp.releaseObject()
        sb.release()

        # Try to clean up the event channel, if it was created
        context = None
        try:
            channel = self._root.resolve(
                URI.stringToName('TEST_APPENDER/TEST_EVT_CH1'))
            channel = channel._narrow(CosEventChannelAdmin.EventChannel)
            channel.destroy()
        except:
            pass

        # Clean up naming context, too
        try:
            context = self._root.resolve(URI.stringToName('TEST_APPENDER'))
            context = context._narrow(CosNaming.NamingContext)
            self._root.unbind(URI.stringToName('TEST_APPENDER'))
            context.destroy()
        except:
            pass

        # Do all application shutdown before calling the base class tearDown,
        # or failures will probably occur.
        scatest.CorbaTestCase.tearDown(self)
    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)
Exemple #3
0
    def test_RestartDomainConnectEvents(self):
        # launch DomainManager
        self._nb_domMgr, self._domMgr = self.launchDomainManager()
        self.assertNotEqual(self._domMgr, None)
        # get domain name
        domain_name = self._domMgr._get_name()
        self.assertNotEqual(domain_name, None)

        # check ODM/IDM channel
        ns_ODM = URI.stringToName("%s/%s" % (domain_name, "ODM_Channel"))
        ns_IDM = URI.stringToName("%s/%s" % (domain_name, "IDM_Channel"))
        orig_ODM_ref = self._root.resolve(ns_ODM)
        orig_IDM_ref = self._root.resolve(ns_IDM)
        self.assertNotEqual(orig_ODM_ref, None)
        self.assertNotEqual(orig_IDM_ref, None)

        ## kill domain manager
        os.kill(self._nb_domMgr.pid, signal.SIGKILL)
        if not self.waitTermination(self._nb_domMgr, 5.0):
            self.fail("Domain Manager Failed to Die")

        # remove old log file
        try:
            os.remove("./sdr/domtest.log")
        except:
            pass

        # restart domain manager
        self._nb_domMgr, self._domMgr = self.launchDomainManager(
            loggingURI='file://' + os.getcwd() + '/domtest.cfg', debug=3)
        self.assertNotEqual(self._domMgr, None)
        # get domain name
        domain_name = self._domMgr._get_name()
        self.assertNotEqual(domain_name, None)

        # check ODM/IDM channel
        ns_ODM = URI.stringToName("%s/%s" % (domain_name, "ODM_Channel"))
        ns_IDM = URI.stringToName("%s/%s" % (domain_name, "IDM_Channel"))
        orig_ODM_ref = self._root.resolve(ns_ODM)
        orig_IDM_ref = self._root.resolve(ns_IDM)
        self.assertNotEqual(orig_ODM_ref, None)
        self.assertNotEqual(orig_IDM_ref, None)

        # check for failed create channel message
        cnt = -1
        try:
            f = open("./sdr/domtest.log")
            cnt = 0
            for x in f.readlines():
                if re.search('.*[ODM|IDM] Channel create FAILED.*', x):
                    cnt += 1
        except:
            pass

        self.assertEqual(cnt, 0)
Exemple #4
0
 def _process_binding(self, binding, orb, filter):
     if filtered([URI.nameToString(binding.binding_name)], filter):
         # Do not pass anything which does not pass the filter
         return
     trimmed_filter = trim_filter(deepcopy(filter))
     with self._mutex:
         # Process a binding, creating the correct child type for it and
         # adding that child to this node's children.
         if binding.binding_type == CosNaming.nobject:
             # This is a leaf node; either a component or a manager.  The
             # specific type can be determined from the binding name kind.
             if binding.binding_name[0].kind == "mgr":
                 name = URI.nameToString(binding.binding_name)
                 obj = self._context.resolve(binding.binding_name)
                 if not obj:
                     leaf = Zombie(name, self)
                     return
                 obj = obj._narrow(RTM.Manager)
                 try:
                     leaf = Manager(name, self, obj, dynamic=self.dynamic)
                 except CORBA.OBJECT_NOT_EXIST:
                     # Manager zombie
                     leaf = Zombie(name, self)
                 except CORBA.TRANSIENT:
                     # Manager zombie
                     leaf = Zombie(name, self)
                 self._add_child(leaf)
             elif binding.binding_name[0].kind == "rtc":
                 name = URI.nameToString(binding.binding_name)
                 obj = self._context.resolve(binding.binding_name)
                 try:
                     obj = obj._narrow(RTC.RTObject)
                 except CORBA.TRANSIENT, e:
                     if e.args[0] == TRANSIENT_ConnectFailed:
                         self._add_child(Zombie(name, self))
                         return
                     else:
                         raise
                 except CORBA.OBJECT_NOT_EXIST:
                     self._add_child(Zombie(name, self))
                     return
                 try:
                     leaf = Component(name, self, obj, dynamic=self.dynamic)
                 except CORBA.OBJECT_NOT_EXIST:
                     # Component zombie
                     leaf = Zombie(name, self, dynamic=self.dynamic)
                 except CORBA.TRANSIENT, e:
                     if e.args[0] == TRANSIENT_ConnectFailed:
                         self._add_child(Zombie(name, self))
                         return
                     else:
                         raise
                 self._add_child(leaf)
    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")
Exemple #6
0
    def createEventChannel(self, eventChannelName, domainName=None, force=False):
        """
        Creates an event channel, if it already exists return it. The
        event channel is bound into the name service as 'eventChannelName',
        in the context specified by 'domainName', or the root naming context
        if 'domainName' is not given.

        If force == True and the event channel already exists, destroy it and create a new one.
        """
        eventChannel = self.getEventChannel(eventChannelName, domainName)
        if eventChannel:
            if force or eventChannel._non_existent():
                self.destroyEventChannel(eventChannelName, domainName)
            else:
                return eventChannel._narrow(CosEventChannelAdmin.EventChannel)

        factory = self.getEventChannelFactory()
        if not factory:
            return None

        name = self._getEventChannelName(eventChannelName, domainName)
        key = [CosNaming.NameComponent("EventChannel","object interface")]
        criteria = [CosLifeCycle.NameValuePair(name="InsName",value=any.to_any(name))]

        try:
            eventChannel = factory.create_object(key,criteria)._narrow(CosEventChannelAdmin.EventChannel)
        except:
            return None

        bindingName = URI.stringToName(name)
        self.rootContext.rebind(bindingName, eventChannel)

        return eventChannel
    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_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_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)
Exemple #10
0
  def resolveBindings(self, bind, name_context, parent):
    res = []
    prefix=parent

    if parent :
      prefix += "/"

    name = prefix + URI.nameToString(bind.binding_name)
    if bind.binding_type == CosNaming.nobject:
      if bind.binding_name[0].kind == "rtc":
        obj = name_context.resolve(bind.binding_name)
        try:
          obj._non_existent()
          obj = obj._narrow(RTObject)
          res = [[name, obj]]
          self.object_list[name] = obj
        except:
          obj = None
          res = [[name, obj]]
      else:
        pass
        #self.object_list[name] = None
    else:
      ctx = name_context.resolve(bind.binding_name)
      ctx = ctx._narrow(CosNaming.NamingContext)
      parent = name
      res = self.getRTObjectList( ctx, parent)
    return res
 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=9)
     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_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=9)
     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_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

        nb = Popen("../../control/framework/nodeBooter -D --domainname %s -debug 9 --nopersist" % (domainName), cwd=scatest.getSdrPath(), shell=True)
        time.sleep(5)

        # Test that the name exists and is a DomainManager
        domMgr = self._root.resolve(domainMgrURI)._narrow(CF.DomainManager)
        self.assertNotEqual(domMgr, None)

        # Kill the nodebooter
        os.kill(nb.pid, signal.SIGINT)
        time.sleep(5) # Give it time to shutdown
        self.assertEqual(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
Exemple #14
0
 def _getComponents(self):
     # Get references to the waveform's components.
     components = {}
     for compName in self._app._get_componentNamingContexts():
         usageName = compName.elementId.split('/')[-1]
         components[usageName] = self._root.resolve(URI.stringToName(compName.elementId))._narrow(CF.Resource)
     return components
Exemple #15
0
    def test_cpp_DirectoryLoad(self):
        self.assertNotEqual(self._domMgr, None)

        # Verify in the devices cache is emtpy
        componentDir = os.path.join(scatest.getSdrPath(), "dom", "components",
                                    "CommandWrapperWithDirectoryLoad")
        deviceCacheDir = os.path.join(scatest.getSdrCache(),
                                      ".ExecutableDevice_node",
                                      "ExecutableDevice1", "components",
                                      "CommandWrapperWithDirectoryLoad")
        if os.path.exists(deviceCacheDir):
            os.system("rm -rf %s" % deviceCacheDir)

        self.assertEqual(len(self._domMgr._get_applicationFactories()), 0)
        self.assertEqual(len(self._domMgr._get_applications()), 0)

        self._domMgr.installApplication(
            "/waveforms/CommandWrapperWithDirectoryLoad/CommandWrapper.sad.xml"
        )
        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        self.assertEqual(len(self._domMgr._get_applications()), 0)

        # Ensure the expected device is available
        devBooter, devMgr = self.launchDeviceManager(
            "/nodes/test_ExecutableDevice_node/DeviceManager.dcd.xml")
        self.assertNotEqual(devMgr, None)
        self.assertEqual(len(devMgr._get_registeredDevices()), 1)
        device = devMgr._get_registeredDevices()[0]

        appFact = self._domMgr._get_applicationFactories()[0]

        app = appFact.create(appFact._get_name(), [], [])  # LOOK MA, NO DAS!

        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        self.assertEqual(len(self._domMgr._get_applications()), 1)

        # Verify that properties have been changed from their defaults
        self.assertEqual(len(app._get_componentNamingContexts()), 1)
        compName = app._get_componentNamingContexts()[0]
        comp = self._root.resolve(URI.stringToName(
            compName.elementId))._narrow(CF.Resource)
        self.assertNotEqual(comp, None)

        cmd = comp.query([
            CF.DataType(id="DCE:a4e7b230-1d17-4a86-aeff-ddc6ea3df26e",
                        value=any.to_any(None))
        ])[0]
        args = comp.query([
            CF.DataType(id="DCE:5d8bfe8d-bc25-4f26-8144-248bc343aa53",
                        value=any.to_any(None))
        ])[0]
        self.assertEqual(cmd.value._v, "/bin/echo")
        self.assertEqual(args.value._v, ["Hello World"])

        app.stop()
        app.releaseObject()
        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        self.assertEqual(len(self._domMgr._get_applications()), 0)

        self._domMgr.uninstallApplication(appFact._get_identifier())
Exemple #16
0
    def proc_bd(self, bd, name_context, parent) :
#        print '-------------------------------------------------------------------'
#        print 'bd= ', bd
#        print 'name_context= ', name_context
#        print 'parent= ', parent
        rslt = []
        pre = ""
        if parent :
            pre = parent + "/"
        nam = pre + URI.nameToString(bd.binding_name)
        if bd.binding_type == CosNaming.nobject :
            tmp = name_context.resolve(bd.binding_name)
            self.obj_list[nam]=tmp
            print 'objcet '+nam+' was listed.'
            try :
                tmp = tmp._narrow(RTC.RTObject)
            except :
                print nam+' is not RTC.'
                tmp = None
            try :
                if tmp :
                   rslt = [[nam, tmp]]
                   self.rtc_handles[nam]=RtcHandle(nam,self,tmp)
                   print 'handle for '+nam+' was created.'
                else :
                   pass
            except :
                print nam+' is not alive.' , sys.exc_info()[0]
                pass
        else :
            tmp = name_context.resolve(bd.binding_name)
            tmp = tmp._narrow(CosNaming.NamingContext)
            rslt = self.list_obj1(tmp, nam)
        return rslt
Exemple #17
0
    def destroyEventChannel(self, eventChannelName, domainName=None):
        """
        Destroys an existing event channel.
        """
        eventChannel = self.getEventChannel(eventChannelName, domainName)
        if not eventChannel:
            return

        # Forcibly unbind the name first.
        nameBinding = URI.stringToName(self._getEventChannelName(eventChannelName, domainName))
        try:
            self.rootContext.unbind(nameBinding)
        except:
            pass

        # Try to destroy the EventChannel, noting that it could be
        # unreachable even if it was found.
        try:
            # omniEvents requires a small pause to allow the EventChannel
            # to be fully destroyed, otherwise a subsequent creation may
            # fail (as though it still existed).
            eventChannel.destroy()
            while not eventChannel._non_existent():
                _time.sleep(0.1)
        except:
            pass
    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_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

        nb = Popen("../../control/framework/nodeBooter -D --domainname %s -debug 9 --nopersist" % (domainName), cwd=scatest.getSdrPath(), shell=True)
        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
Exemple #20
0
 def proc_bd(self, bd, name_context, parent):
     #        print('-------------------------------------------------------------------')
     #        print('bd= ', bd)
     #        print('name_context= ', name_context)
     #        print('parent= ', parent)
     rslt = []
     pre = ""
     if parent:
         pre = parent + "/"
     nam = pre + URI.nameToString(bd.binding_name)
     if bd.binding_type == CosNaming.nobject:
         tmp = name_context.resolve(bd.binding_name)
         self.obj_list[nam] = tmp
         print('objcet ' + nam + ' was listed.')
         try:
             tmp = tmp._narrow(RTC.RTObject)
         except BaseException:
             print(nam + ' is not RTC.')
             tmp = None
         try:
             if tmp:
                 rslt = [[nam, tmp]]
                 self.rtc_handles[nam] = RtcHandle(nam, self, tmp)
                 print('handle for ' + nam + ' was created.')
             else:
                 pass
         except BaseException:
             print(nam + ' is not alive.')
             pass
     else:
         tmp = name_context.resolve(bd.binding_name)
         tmp = tmp._narrow(CosNaming.NamingContext)
         rslt = self.list_obj1(tmp, nam)
     return rslt
Exemple #21
0
    def bind_context(self, n, nc, force=False):
        key = URI.nameToString(n)
        if not force and self.object_table.has_key(key) :
            raise CosNaming.NamingContext.AlreadyBound()

        self.object_table[key] = (nc, CosNaming.ncontext)
        return
Exemple #22
0
    def destroyEventChannel(self, eventChannelName, domainName=None):
        """
        Destroys an existing event channel.
        """
        eventChannel = self.getEventChannel(eventChannelName, domainName)
        if not eventChannel:
            return

        # Forcibly unbind the name first.
        nameBinding = URI.stringToName(
            self._getEventChannelName(eventChannelName, domainName))
        try:
            self.rootContext.unbind(nameBinding)
        except:
            pass

        # Try to destroy the EventChannel, noting that it could be
        # unreachable even if it was found.
        try:
            # omniEvents requires a small pause to allow the EventChannel
            # to be fully destroyed, otherwise a subsequent creation may
            # fail (as though it still existed).
            eventChannel.destroy()
            while not eventChannel._non_existent():
                time.sleep(0.1)
        except:
            pass
 def _getComponents(self):
     # Get references to the waveform's components.
     components = {}
     for compName in self._app._get_componentNamingContexts():
         usageName = compName.elementId.split('/')[-1]
         components[usageName] = self._root.resolve(URI.stringToName(compName.elementId))._narrow(CF.Resource)
     return components
    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")
Exemple #25
0
 def rebind(self, name, object):
     uri = URI.nameToString(name)
     log.debug('Rebinding "%s" into virtual NamingContext', uri)
     self.__lock.acquire()
     try:
         self.__context[uri] = object
     finally:
         self.__lock.release()
 def test_NSCleanup(self):
     domain_name = self._domMgr._get_name()
     ns_domMgr = URI.stringToName("%s/%s" % (domain_name, domain_name))
     ns_domMgrCtx = URI.stringToName("%s" % (domain_name))
     ns_ODM = URI.stringToName("%s/%s" % (domain_name, "ODM_Channel"))
     ns_IDM = URI.stringToName("%s/%s" % (domain_name, "IDM_Channel"))
     domCtx_ref = self._root.resolve(ns_domMgrCtx)
     domMgr_ref = self._root.resolve(ns_domMgr)
     ODM_ref = self._root.resolve(ns_ODM)
     IDM_ref = self._root.resolve(ns_IDM)
     self.assertNotEqual(domCtx_ref, None)
     self.assertNotEqual(domMgr_ref, None)
     self.assertNotEqual(ODM_ref, None)
     self.assertNotEqual(IDM_ref, None)
     os.kill(self._domainBooter.pid, signal.SIGINT)
     self.waitTermination(self._domainBooter)
     self.assertRaises(CosNaming.NamingContext.NotFound, self._root.resolve, ns_domMgrCtx)
 def test_NSCleanup(self):
     domain_name = self._domMgr._get_name()
     ns_domMgr = URI.stringToName("%s/%s" % (domain_name, domain_name))
     ns_domMgrCtx = URI.stringToName("%s" % (domain_name))
     ns_ODM = URI.stringToName("%s/%s" % (domain_name, "ODM_Channel"))
     ns_IDM = URI.stringToName("%s/%s" % (domain_name, "IDM_Channel"))
     domCtx_ref = self._root.resolve(ns_domMgrCtx)
     domMgr_ref = self._root.resolve(ns_domMgr)
     ODM_ref = self._root.resolve(ns_ODM)
     IDM_ref = self._root.resolve(ns_IDM)
     self.assertNotEqual(domCtx_ref, None)
     self.assertNotEqual(domMgr_ref, None)
     self.assertNotEqual(ODM_ref, None)
     self.assertNotEqual(IDM_ref, None)
     os.kill(self._domainBooter.pid, signal.SIGINT)
     self.waitTermination(self._domainBooter)
     self.assertRaises(CosNaming.NamingContext.NotFound, self._root.resolve, ns_domMgrCtx)
    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()
    def test_ApplicationFactoryCreateURIOverride(self):
        domNB, domMgr = self.launchDomainManager(loggingURI="dom/mgr/logging.properties")
        self.assertNotEqual(domMgr, None)

        # Launch a device manager
        devNB, devMgr = self.launchDeviceManager(
            "/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml", loggingURI="dev/mgr/logging.properties"
        )
        self.assertNotEqual(domMgr, None)

        # Double check the DomainManager LOGGING_CONFIG_URI
        prop = CF.DataType(id="LOGGING_CONFIG_URI", value=any.to_any(None))
        result = domMgr.query([prop])
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0].id, "LOGGING_CONFIG_URI")
        devLoggingConfigURI = result[0].value._v
        expectedDomLoggingConfigUri = "file://" + os.path.join(scatest.getSdrPath(), "dom/mgr/logging.properties")
        self.assertEqual(devLoggingConfigURI, expectedDomLoggingConfigUri)

        # Launch an application
        domMgr.installApplication("/waveforms/CommandWrapper/CommandWrapper.sad.xml")
        self.assertEqual(len(domMgr._get_applicationFactories()), 1)
        self.assertEqual(len(domMgr._get_applications()), 0)

        appFact = domMgr._get_applicationFactories()[0]
        uriOverride = CF.DataType(id="LOGGING_CONFIG_URI", value=any.to_any("sca:///mgr/logging.properties"))
        app = appFact.create(appFact._get_name(), [uriOverride], [])

        # Get the desired component
        self.assertEqual(len(app._get_componentNamingContexts()), 1)
        compName = app._get_componentNamingContexts()[0]
        comp = self._root.resolve(URI.stringToName(compName.elementId))._narrow(CF.Resource)
        self.assertNotEqual(comp, None)

        # Check the components exec params
        execparams = comp.query([CF.DataType(id="DCE:85d133fd-1658-4e4d-b3ff-1443cd44c0e2", value=any.to_any(None))])[0]
        args = any.from_any(execparams.value)
        execparams = {}
        for b in args:
            a = eval(b)
            name = a[0]
            value = a[1]
            execparams[name] = value

        self.assert_(execparams.has_key("LOGGING_CONFIG_URI"))
        self.assertEqual(execparams["LOGGING_CONFIG_URI"].split("?fs=")[0], "sca:///mgr/logging.properties")
        execparamObj = self._orb.string_to_object(execparams["LOGGING_CONFIG_URI"].split("?fs=")[1])
        # Need to compare actual objects since the IOR strings could potentially differ for the same object
        self.assert_(domMgr._get_fileMgr()._is_equivalent(execparamObj))

        # Launch an application with a C++ component to exercise Resource_impl logging configure
        domMgr.installApplication("/waveforms/TestCppProps/TestCppProps.sad.xml")
        self.assertEqual(len(domMgr._get_applicationFactories()), 2)
        for appFact in domMgr._get_applicationFactories():
            if appFact._get_name() == "TestCppProps":
                app = appFact.create(appFact._get_name(), [uriOverride], [])
                break
        self.assertEqual(len(domMgr._get_applications()), 2)
    def _test_py_SharedLibraryLoad(self, node):
        self.assertNotEqual(self._domMgr, None)

        self.assertEqual(len(self._domMgr._get_applicationFactories()), 0)
        self.assertEqual(len(self._domMgr._get_applications()), 0)

        # Verify in the devices cache is empty
        componentDir = os.path.join(scatest.getSdrPath(), "dom", "components", "pythonSoftpkgDep")
        deviceCacheDir = os.path.join(scatest.getSdrCache(), ".test_GPP_node", "GPP_1", "components", "pythonSoftpkgDep")
        if os.path.exists(deviceCacheDir):
            os.system("rm -rf %s" % deviceCacheDir)

        self._domMgr.installApplication("/waveforms/python_softpkg_deps/python_softpkg_deps.sad.xml")
        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        self.assertEqual(len(self._domMgr._get_applications()), 0)

        # Ensure the expected device is available
        devBooter, devMgr = self.launchDeviceManager(node)
        self.assertNotEqual(devMgr, None)
        self.assertEqual(len(devMgr._get_registeredDevices()), 1)
        device = devMgr._get_registeredDevices()[0]

        appFact = self._domMgr._get_applicationFactories()[0]

        app = appFact.create(appFact._get_name(), [], []) # LOOK MA, NO DAS!

        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        self.assertEqual(len(self._domMgr._get_applications()), 1)

        # Verify that properties have been changed from their defaults
        self.assertEqual(len(app._get_componentNamingContexts()), 1)
        compName = app._get_componentNamingContexts()[0]
        comp = self._root.resolve(URI.stringToName(compName.elementId))._narrow(CF.Resource)
        self.assertNotEqual(comp, None)

        cmd = comp.query([CF.DataType(id="prop1", value=any.to_any(None))])[0]
        self.assertEqual(cmd.value._v, "hello")
        cmd = comp.query([CF.DataType(id="prop2", value=any.to_any(None))])[0]
        self.assertEqual(cmd.value._v, "world")
        cmd = comp.query([CF.DataType(id="prop3", value=any.to_any(None))])[0]
        self.assertEqual(cmd.value._v, "helloworld")

        comp.start()
        
        cmd = comp.query([CF.DataType(id="prop1", value=any.to_any(None))])[0]
        self.assertEqual(cmd.value._v, "jones")
        cmd = comp.query([CF.DataType(id="prop2", value=any.to_any(None))])[0]
        self.assertEqual(cmd.value._v, "goober")
        cmd = comp.query([CF.DataType(id="prop3", value=any.to_any(None))])[0]
        self.assertEqual(cmd.value._v, "testing")

        app.stop()
        app.releaseObject()
        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        self.assertEqual(len(self._domMgr._get_applications()), 0)

        self._domMgr.uninstallApplication(appFact._get_identifier())
Exemple #31
0
    def test_ApplicationFactoryCreateURIOverride(self):
        domNB, domMgr = self.launchDomainManager(loggingURI="dom/mgr/logging.properties")
        self.assertNotEqual(domMgr, None)

        # Launch a device manager
        devNB, devMgr = self.launchDeviceManager("/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml", loggingURI="dev/mgr/logging.properties")
        self.assertNotEqual(domMgr, None)

        # Double check the DomainManager LOGGING_CONFIG_URI
        prop = CF.DataType(id="LOGGING_CONFIG_URI", value=any.to_any(None))
        result = domMgr.query([prop])
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0].id, "LOGGING_CONFIG_URI")
        devLoggingConfigURI = result[0].value._v
        expectedDomLoggingConfigUri = "file://" + os.path.join(scatest.getSdrPath(), "dom/mgr/logging.properties")
        self.assertEqual(devLoggingConfigURI, expectedDomLoggingConfigUri)

        # Launch an application
        domMgr.installApplication("/waveforms/CommandWrapper/CommandWrapper.sad.xml")
        self.assertEqual(len(domMgr._get_applicationFactories()), 1)
        self.assertEqual(len(domMgr._get_applications()), 0)

        appFact = domMgr._get_applicationFactories()[0]
        uriOverride = CF.DataType(id="LOGGING_CONFIG_URI", value=any.to_any("sca:///mgr/logging.properties"))
        app = appFact.create(appFact._get_name(), [uriOverride], [])

        # Get the desired component
        self.assertEqual(len(app._get_componentNamingContexts()), 1)
        compName = app._get_componentNamingContexts()[0]
        comp = self._root.resolve(URI.stringToName(compName.elementId))._narrow(CF.Resource)
        self.assertNotEqual(comp, None)

        # Check the components exec params
        execparams = comp.query([CF.DataType(id="DCE:85d133fd-1658-4e4d-b3ff-1443cd44c0e2", value=any.to_any(None))])[0]
        args = any.from_any(execparams.value)
        execparams = {}
        for b in args:
            a = eval(b)
            name = a[0]
            value = a[1]
            execparams[name] = value

        self.assert_(execparams.has_key("LOGGING_CONFIG_URI"))
        self.assertEqual(execparams["LOGGING_CONFIG_URI"].split("?fs=")[0], "sca:///mgr/logging.properties")
        execparamObj = self._orb.string_to_object(execparams["LOGGING_CONFIG_URI"].split("?fs=")[1])
        # Need to compare actual objects since the IOR strings could potentially differ for the same object
        self.assert_(domMgr._get_fileMgr()._is_equivalent(execparamObj))

        # Launch an application with a C++ component to exercise Resource_impl logging configure
        domMgr.installApplication("/waveforms/TestCppProps/TestCppProps.sad.xml")
        self.assertEqual(len(domMgr._get_applicationFactories()), 2)
        for appFact in domMgr._get_applicationFactories():
            if appFact._get_name() == "TestCppProps":
                app = appFact.create(appFact._get_name(), [uriOverride], [])
                break
        self.assertEqual(len(domMgr._get_applications()), 2)
    def setup (self, domainName, *args):
        self.domainName = domainName
        try:
            self.domMgr = self.inc.resolve(URI.stringToName('/'.join([domainName]*2)))
        except:
            print >>sys.stderr, "Unable to connect to domain manager for domain", domainName
            sys.exit(1)

        print 'Arguments: ', ' '.join(args)
        self.initialize(*args)
Exemple #33
0
 def bind(self, name, object):
     uri = URI.nameToString(name)
     self.__lock.acquire()
     try:
         if uri in self.__context:
             raise CosNaming.NamingContext.AlreadyBound()
         log.debug('Binding "%s" into virtual NamingContext', uri)
         self.__context[uri] = object
     finally:
         self.__lock.release()
Exemple #34
0
    def setup(self, domainName, *args):
        self.domainName = domainName
        try:
            self.domMgr = self.inc.resolve(
                URI.stringToName('/'.join([domainName] * 2)))
        except:
            print >> sys.stderr, "Unable to connect to domain manager for domain", domainName
            sys.exit(1)

        print 'Arguments: ', ' '.join(args)
        self.initialize(*args)
Exemple #35
0
 def next_one(self):
     b = None
     res = True
     try:
       x = self.keys.pop(0)
       name = URI.stringToName(x)
       b = CosNaming.Binding(name, self.object_table[x][1])
     except:
       res = False
       self.destroy()
     return (res, b)
Exemple #36
0
    def bind_one(self, n, obj, force=False):
        if len(n) == 1:
            key = URI.nameToString(n)
            if not force and self.object_table.has_key(key):
                raise CosNaming.NamingContext.AlreadyBound()

            #print(obj)
            self.object_table[key] = (obj, CosNaming.nobject)
            return
        else:
            raise CosNaming.NamingContext.InvalidName()
        return
Exemple #37
0
    def rebind_context(self, n, nc):
        key = URI.nameToString(n)
        if self.object_table.has_key(key) :
            try:
                self.object_table[key][1].destroy()
            except e:
                raise e

            self.object_table[key] = (obj, CosNaming.ncontext)
        else:
            raise CosNaming.NamingContext.NotFound(CosNaming.NamingContext.missing_node, n)
        return
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)
Exemple #39
0
 def unbind(self, n):
     if len(n) == 1:
         key = URI.nameToString(n)
         if self.object_table.has_key(key) :
             del self.object_table[key]
         else:
             pass
             #raise CosNaming.NamingContext.NotFound(CosNaming.NamingContext.missing_node, n)
     else:
         cxt = self.get_next_context(n)
         cxt.unbind(n[1:])
         pass
     return 
    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)
Exemple #41
0
    def test_py_BasicOperation(self):
        self.assertNotEqual(self._domMgr, None)

        self.assertEqual(len(self._domMgr._get_applicationFactories()), 0)
        self.assertEqual(len(self._domMgr._get_applications()), 0)

        self._domMgr.installApplication(
            "/waveforms/CommandWrapperOsProcessor/CommandWrapper.sad.xml")
        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        self.assertEqual(len(self._domMgr._get_applications()), 0)

        # Ensure the expected device is available
        devBooter, devMgr = self.launchDeviceManager(
            "/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml")
        self.assertNotEqual(devMgr, None)
        self.assertEqual(len(devMgr._get_registeredDevices()), 1)
        device = devMgr._get_registeredDevices()[0]

        appFact = self._domMgr._get_applicationFactories()[0]

        app = appFact.create(appFact._get_name(), [], [])  # LOOK MA, NO DAS!

        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        self.assertEqual(len(self._domMgr._get_applications()), 1)

        # Verify that properties have been changed from their defaults
        self.assertEqual(len(app._get_componentNamingContexts()), 1)
        compName = app._get_componentNamingContexts()[0]
        comp = self._root.resolve(URI.stringToName(
            compName.elementId))._narrow(CF.Resource)
        self.assertNotEqual(comp, None)

        cmd = comp.query([
            CF.DataType(id="DCE:a4e7b230-1d17-4a86-aeff-ddc6ea3df26e",
                        value=any.to_any(None))
        ])[0]
        args = comp.query([
            CF.DataType(id="DCE:5d8bfe8d-bc25-4f26-8144-248bc343aa53",
                        value=any.to_any(None))
        ])[0]
        self.assertEqual(cmd.value._v, "/bin/echo")
        self.assertEqual(args.value._v, ["Hello World"])

        app.stop()
        app.releaseObject()
        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        self.assertEqual(len(self._domMgr._get_applications()), 0)

        self._domMgr.uninstallApplication(appFact._get_identifier())
    def tearDown(self):
        self.comp.releaseObject()

        # Try to clean up the event channel, if it was created
        context = None
        try:
            channel = self._root.resolve(URI.stringToName('TEST_APPENDER/TEST_EVT_CH1'))
            channel = channel._narrow(CosEventChannelAdmin.EventChannel)
            channel.destroy()
        except:
            pass

        # Clean up naming context, too
        try:
            context = self._root.resolve(URI.stringToName('TEST_APPENDER'))
            context = context._narrow(CosNaming.NamingContext)
            self._root.unbind(URI.stringToName('TEST_APPENDER'))
            context.destroy()
        except:
            pass

        # Do all application shutdown before calling the base class tearDown,
        # or failures will probably occur.
        scatest.CorbaTestCase.tearDown(self)
Exemple #43
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)
Exemple #44
0
 def next_n(self, how_many):
     res = True
     bl = []
     try:
       n_keys = len(self.keys)
       for i in range(n_keys):
         if i < how_many:
             x = self.keys.pop(0)
             name = URI.stringToName(x)
             val = CosNaming.Binding(name, self.object_table[x][1])
             bl.append(val)
     except:
       res = False
       self.destroy()
     return (res, bl)
Exemple #45
0
    def getEventChannel(self, eventChannelName, domainName=None):
        """
        Returns a reference to an existing event channel, or None if it
        cannot be located.
        """
        nameBinding = URI.stringToName(self._getEventChannelName(eventChannelName, domainName))

        try:
            channel = self.rootContext.resolve(nameBinding)
        except:
            return None

        if channel and not channel._non_existent():
            return channel._narrow(CosEventChannelAdmin.EventChannel)
        return None
Exemple #46
0
    def get_next_context(self, n, force=False):
        key = URI.nameToString([n[0]])

        if self.object_table.has_key(key) :
            if self.object_table[key][1] == CosNaming.ncontext :
                return self.object_table[key][0]
            else:
                raise CosNamingContext.InvalidName()

        else:
           if force :
               nc = NamingContext_i(None, self.names_poa)
               self.object_table[key] = (nc, CosNaming.ncontext)
               return nc
           else:
               raise CosNaming.NamingContext.NotFound(CosNaming.NamingContext.missing_node, n)            
Exemple #47
0
 def resolve(self, n):
     if len(n) == 1:
         key = URI.nameToString(n)
         if self.object_table.has_key(key) :
             if self.object_table[key][1] == CosNaming.nobject:
                 return self.object_table[key][0]
             elif self.object_table[key][1] == CosNaming.ncontext:
                 return self.object_table[key][0]._this()
             else:
                 raise CosNaming.NamingContext.NotFound(CosNaming.NamingContext.missing_node, n)
         else:
             raise CosNaming.NamingContext.NotFound(CosNaming.NamingContext.missing_node, n)
     else:
         cxt = self.get_next_context(n)
         return cxt.resolve(n[1:])
     return None
Exemple #48
0
    def createEventChannel(self,
                           eventChannelName,
                           domainName=None,
                           force=False):
        """
        Creates an event channel, if it already exists return it. The
        event channel is bound into the name service as 'eventChannelName',
        in the context specified by 'domainName', or the root naming context
        if 'domainName' is not given.

        If force == True and the event channel already exists, destroy it and create a new one.
        """
        eventChannel = self.getEventChannel(eventChannelName, domainName)
        if eventChannel:
            if force or eventChannel._non_existent():
                self.destroyEventChannel(eventChannelName, domainName)
            else:
                return eventChannel._narrow(CosEventChannelAdmin.EventChannel)

        factory = self.getEventChannelFactory()
        if not factory:
            return None

        name = self._getEventChannelName(eventChannelName, domainName)
        key = [CosNaming.NameComponent("EventChannel", "object interface")]
        if domainName != None:
            criteria = [
                CosLifeCycle.NameValuePair(name="InsName",
                                           value=any.to_any(domainName + '.' +
                                                            eventChannelName))
            ]
        else:
            criteria = [
                CosLifeCycle.NameValuePair(name="InsName",
                                           value=any.to_any(eventChannelName))
            ]

        try:
            eventChannel = factory.create_object(key, criteria)._narrow(
                CosEventChannelAdmin.EventChannel)
        except:
            return None

        bindingName = URI.stringToName(name)
        self.rootContext.rebind(bindingName, eventChannel)

        return eventChannel
Exemple #49
0
    def getEventChannel(self, eventChannelName, domainName=None):
        """
        Returns a reference to an existing event channel, or None if it
        cannot be located.
        """
        nameBinding = URI.stringToName(self._getEventChannelName(eventChannelName, domainName))
        try:
            channel = self.rootContext.resolve(nameBinding)
        except:
            return None

        try:
            if channel and not channel._non_existent():
                return channel._narrow(CosEventChannelAdmin.EventChannel)
        except CORBA.Exception:
            return None
        return None
    def test_cpp_DirectoryLoad(self):
        self.assertNotEqual(self._domMgr, None)

        # Verify in the devices cache is emtpy
        componentDir = os.path.join(scatest.getSdrPath(), "dom", "components", "CommandWrapperWithDirectoryLoad")
        deviceCacheDir = os.path.join(scatest.getSdrCache(), ".ExecutableDevice_node", "ExecutableDevice1", "components", "CommandWrapperWithDirectoryLoad")
        if os.path.exists(deviceCacheDir):
            os.system("rm -rf %s" % deviceCacheDir)

        self.assertEqual(len(self._domMgr._get_applicationFactories()), 0)
        self.assertEqual(len(self._domMgr._get_applications()), 0)

        self._domMgr.installApplication("/waveforms/CommandWrapperWithDirectoryLoad/CommandWrapper.sad.xml")
        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        self.assertEqual(len(self._domMgr._get_applications()), 0)

        # Ensure the expected device is available
        devBooter, devMgr = self.launchDeviceManager("/nodes/test_ExecutableDevice_node/DeviceManager.dcd.xml")
        self.assertNotEqual(devMgr, None)
        self.assertEqual(len(devMgr._get_registeredDevices()), 1)
        device = devMgr._get_registeredDevices()[0]

        appFact = self._domMgr._get_applicationFactories()[0]

        app = appFact.create(appFact._get_name(), [], []) # LOOK MA, NO DAS!

        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        self.assertEqual(len(self._domMgr._get_applications()), 1)

        # Verify that properties have been changed from their defaults
        self.assertEqual(len(app._get_componentNamingContexts()), 1)
        compName = app._get_componentNamingContexts()[0]
        comp = self._root.resolve(URI.stringToName(compName.elementId))._narrow(CF.Resource)
        self.assertNotEqual(comp, None)

        cmd = comp.query([CF.DataType(id="DCE:a4e7b230-1d17-4a86-aeff-ddc6ea3df26e", value=any.to_any(None))])[0]
        args = comp.query([CF.DataType(id="DCE:5d8bfe8d-bc25-4f26-8144-248bc343aa53", value=any.to_any(None))])[0]
        self.assertEqual(cmd.value._v, "/bin/echo")
        self.assertEqual(args.value._v, ["Hello World"])

        app.stop()
        app.releaseObject()
        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        self.assertEqual(len(self._domMgr._get_applications()), 0)

        self._domMgr.uninstallApplication(appFact._get_identifier())
    def tearDown(self):
        for devMgr in self._getDeviceManagers():
            try:
                devMgr.shutdown()
            except CORBA.Exception:
                # Ignore all CORBA errors.
                pass

        for devBooter in self._getDeviceBooters():
            self.terminateChild(devBooter)

        if self._domainBooter:
            self.terminateChild(self._domainBooter)

        try:
            self._root.unbind(URI.stringToName(getTestDomainName()))
        except:
            pass
Exemple #52
0
def ORB_start_fun():
    orb_ref = orb

    # get the POA
    obj_poa = orb_ref.orb.resolve_initial_references("RootPOA")
    poaManager = obj_poa._get_the_POAManager()
    poaManager.activate()
        
    ns_obj = orb_ref.orb.resolve_initial_references("NameService")
    rootContext = ns_obj._narrow(CosNaming.NamingContext)
        
    # create the main component object
    orb_ref.OSSIETalk_Obj = OSSIETalk_i(orb_ref, uuid, label, obj_poa)
    OSSIETalk_var = orb_ref.OSSIETalk_Obj._this()
        
    name = URI.stringToName(label)
    rootContext.rebind(name, OSSIETalk_var)

    orb_ref.orb.run()
Exemple #53
0
 def __init__(self, uuid, label):
     # initialize the orb
     self.orb = CORBA.ORB_init()
     
     # get the POA
     obj_poa = self.orb.resolve_initial_references("RootPOA")
     poaManager = obj_poa._get_the_POAManager()
     poaManager.activate()
     
     ns_obj = self.orb.resolve_initial_references("NameService")
     rootContext = ns_obj._narrow(CosNaming.NamingContext)
     
     # create the main component object
     self.__CLASS_NAME___Obj = __CLASS_NAME___i(uuid, label, obj_poa)
     __CLASS_NAME___var = self.__CLASS_NAME___Obj._this()
     
     name = URI.stringToName(label)
     rootContext.rebind(name, __CLASS_NAME___var)
     
     self.orb.run()
    def test_py_BasicOperation(self):
        self.assertNotEqual(self._domMgr, None)

        self.assertEqual(len(self._domMgr._get_applicationFactories()), 0)
        self.assertEqual(len(self._domMgr._get_applications()), 0)

        self._domMgr.installApplication("/waveforms/CommandWrapperOsProcessor/CommandWrapper.sad.xml")
        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        self.assertEqual(len(self._domMgr._get_applications()), 0)

        # Ensure the expected device is available
        devBooter, devMgr = self.launchDeviceManager("/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml")
        self.assertNotEqual(devMgr, None)
        self.assertEqual(len(devMgr._get_registeredDevices()), 1)
        device = devMgr._get_registeredDevices()[0]

        appFact = self._domMgr._get_applicationFactories()[0]

        app = appFact.create(appFact._get_name(), [], []) # LOOK MA, NO DAS!

        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        self.assertEqual(len(self._domMgr._get_applications()), 1)

        # Verify that properties have been changed from their defaults
        self.assertEqual(len(app._get_componentNamingContexts()), 1)
        compName = app._get_componentNamingContexts()[0]
        comp = self._root.resolve(URI.stringToName(compName.elementId))._narrow(CF.Resource)
        self.assertNotEqual(comp, None)

        cmd = comp.query([CF.DataType(id="DCE:a4e7b230-1d17-4a86-aeff-ddc6ea3df26e", value=any.to_any(None))])[0]
        args = comp.query([CF.DataType(id="DCE:5d8bfe8d-bc25-4f26-8144-248bc343aa53", value=any.to_any(None))])[0]
        self.assertEqual(cmd.value._v, "/bin/echo")
        self.assertEqual(args.value._v, ["Hello World"])

        app.stop()
        app.releaseObject()
        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        self.assertEqual(len(self._domMgr._get_applications()), 0)

        self._domMgr.uninstallApplication(appFact._get_identifier())
Exemple #55
0
    def getEventChannelFactory(self):
        """
        Get the EventChannelFactory for this ORB. An initial reference of
        'EventService' is checked first, then the NameService is queried
        for the factory name. Returns None if one cannot be located.
        """
        try:
            factory = self.orb.resolve_initial_references("EventService")
        except:
            factory = None

        if not factory:
            eventFactoryName = URI.stringToName(self.factoryName)
            try:
                factory = self.rootContext.resolve(eventFactoryName)
            except:
                return None

        if factory:
            return factory._narrow(CosLifeCycle.GenericFactory)
        
        return None
 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_FindByAbsoluteNamingService(self):
        from ossie.utils import sb
        comp=sb.Component('PortTest')
        orb = CORBA.ORB_init()
        obj = orb.resolve_initial_references("NameService")
        rootContext = obj._narrow(CosNaming.NamingContext)
        bindingName = URI.stringToName("PortTest2")
        rootContext.rebind(bindingName, comp.ref)

        self.assertNotEqual(self._domMgr, None)
        self.assertNotEqual(self._devMgr, None)

        sadpath = "/waveforms/PortConnectFindByAbsoluteNamingService/PortConnectFindByAbsoluteNamingService.sad.xml"
        self._domMgr.installApplication(sadpath)
        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        appFact = self._domMgr._get_applicationFactories()[0]

        try:
            self._app = appFact.create(appFact._get_name(), [], [])
        except:
            rootContext.unbind(bindingName)
            self.fail("Did not create application PortConnectFindByAbsoluteNamingService")
        components = self._getComponents()

        # Use the TestableObject interface to check that 'PortTest1' has
        # exactly one connection, and that it's connected to 'PortTest2'.
        ids = components['PortTest1'].runTest(0, [])
        if (len(ids) != 1):
            rootContext.unbind(bindingName)
            self.fail("There are more than one connection on PortTest1")
        expectedId = comp.ref._get_identifier()
        if (str(ids[0].value.value()) != expectedId):
            rootContext.unbind(bindingName)
            self.fail("The expected id does not match")
        rootContext.unbind(bindingName)
        sb.domainless._cleanUpLaunchedComponents()
        # ORB initialization
        orb = CORBA.ORB_init()
        obj_poa = orb.resolve_initial_references("RootPOA")
        poaManager = obj_poa._get_the_POAManager()
        poaManager.activate()

        if execparams["FAIL_AT"] == "PreServantCreation":
            raise StandardError

        # Create the component servant object
        component_Obj = FailStartup(execparams)
        component_Var = component_Obj._this()

        if execparams["FAIL_AT"] == "PreNameBinding":
            raise StandardError

        # Bind it to the naming context
        rootContext = orb.string_to_object(execparams['NAMING_CONTEXT_IOR'])
        if rootContext == None:
            raise SystemExit, "Failed to lookup naming context"
        rootContext = rootContext._narrow(CosNaming.NamingContext)
        name = URI.stringToName(execparams['NAME_BINDING'])
        rootContext.rebind(name, component_Var)

        if execparams["FAIL_AT"] == "PreOrbRun":
            raise StandardError
        orb.run()
    finally:
        if orb:
            orb.destroy()