Esempio n. 1
0
 def testRFInfo(self):
     _port = None
     for port in self.comp.ports:
         if port.name == 'RFInfo_in':
             _port = port
             break
     _antennainfo = FRONTEND.AntennaInfo('testAnt', 'testType', 'testSize',
                                         'testDescription')
     _freqrange = FRONTEND.FreqRange(0, 100, [1])
     _feedinfo = FRONTEND.FeedInfo('testFeed', 'testPol', _freqrange)
     _sensorinfo = FRONTEND.SensorInfo('testMission', 'testCollector',
                                       'testRX', _antennainfo, _feedinfo)
     _pathdelays = [
         FRONTEND.PathDelay(100, 200),
         FRONTEND.PathDelay(300, 400)
     ]
     _rfcapabilities = FRONTEND.RFCapabilities(FRONTEND.FreqRange(1, 2, []),
                                               FRONTEND.FreqRange(3, 4, []))
     _additionalinfo = [
         CF.DataType(id='a', value=any.to_any(1)),
         CF.DataType(id='b', value=any.to_any(2)),
         CF.DataType(id='c', value=any.to_any(3))
     ]
     _rfinfopkt = FRONTEND.RFInfoPkt('TestID', 256.0, 101.0, 412.0, False,
                                     _sensorinfo, _pathdelays,
                                     _rfcapabilities, _additionalinfo)
     _port.ref._set_rfinfo_pkt(_rfinfopkt)
Esempio n. 2
0
 def getProp(self):
     content = []
     for member in self.getMembers():
         content.append(
             CF.DataType(id=member[0], value=_any.to_any(member[1])))
     retval = CF.DataType(id=self.getId(), value=_any.to_any(content))
     return retval
Esempio n. 3
0
    def test_DeviceManagerURIOverride(self):
        # Test that the device manager DCD can override the log4cxx URI
        domNB, domMgr = self.launchDomainManager(loggingURI="")
        self.assertNotEqual(domMgr, None)

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

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

        # Check the devices exec params
        self.assertEqual(len(devMgr._get_registeredDevices()), 1)
        device = devMgr._get_registeredDevices()[0]
        execparams = device.query([CF.DataType(id="DCE:85d133fd-1658-4e4d-b3ff-1443cd44c0e2", value=any.to_any(None))])[0]
        args = execparams.value._v.split()
        execparams = {}
        while len(args) > 0:
            name = args.pop(0)
            value = args.pop(0)
            execparams[name] = value

        self.assert_(execparams.has_key("LOGGING_CONFIG_URI"))
        devMgrFileSysIOR = self._orb.object_to_string(devMgr._get_fileSys())
        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_(devMgr._get_fileSys()._is_equivalent(execparamObj))
Esempio n. 4
0
    def test_AppReleaseUnloadFail(self):
        self.preconditions()

        # Make the device throw a CF.InvalidFileName exception on unload.
        props = [
            CF.DataType(id="DCE:58f5720f-3a33-4056-8359-6b560613815d",
                        value=any.to_any("unload")),
            CF.DataType(id="DCE:7f4ca822-5497-43d0-b92d-fe97c561e450",
                        value=any.to_any("CF.InvalidFileName"))
        ]
        self._device.configure(props)

        # Test that the exception occurs as expected
        self._device.load(self._domMgr._get_fileMgr(),
                          "/waveforms/CapacityUsage/CapacityUsage.sad.xml",
                          CF.LoadableDevice.EXECUTABLE)
        self.assertRaises(CF.InvalidFileName, self._device.unload,
                          "/waveforms/CapacityUsage/CapacityUsage.sad.xml")

        # Create an application that uses capacity, then release it
        self._domMgr.installApplication(
            "/waveforms/CapacityUsage/CapacityUsage.sad.xml")
        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        appFact = self._domMgr._get_applicationFactories()[0]
        app = appFact.create(appFact._get_identifier(), [], [])
        app.releaseObject()

        # Verify that the capacity has been returned to the device.
        prop = CF.DataType(id="DCE:5636c210-0346-4df7-a5a3-8fd34c5540a8",
                           value=any.to_any(None))
        props = self._device.query([prop])
        self.assertEqual(props[0].value._v, 100000000)
Esempio n. 5
0
    def test_propertyExceptionsSeq(self):
        self.preconditions()

        seq_short = CF.DataType(
            id='seq_short',
            value=CORBA.Any(CORBA.TypeCode("IDL:omg.org/CORBA/ShortSeq:1.0"),
                            [11, 22]))
        self._app.configure([seq_short])

        seq_short = CF.DataType(id='seq_short', value=any.to_any([33, 44]))
        self.assertRaises(CF.PropertySet.InvalidConfiguration,
                          self._app.configure, [seq_short])

        seq_long = CF.DataType(id='seq_long', value=any.to_any([55, 66]))
        self.assertRaises(CF.PropertySet.PartialConfiguration,
                          self._app.configure, [seq_short, seq_long])

        # Long sequence should have changed and short did not
        for r in self._app.query([]):
            if r.id == 'seq_long':
                self.assertEquals(r.value.value()[0], 55)
                self.assertEquals(r.value.value()[1], 66)
            elif r.id == 'seq_short':
                self.assertEquals(r.value.value()[0], 11)
                self.assertEquals(r.value.value()[1], 22)
Esempio n. 6
0
    def test_AllocateFailUnexpectedException(self):
        self.preconditions()

        # Make the device throw a generic Python exception on allocate, which will become
        # a CORBA::UNKNOWN to the DomainManager
        props = [
            CF.DataType(id="DCE:58f5720f-3a33-4056-8359-6b560613815d",
                        value=any.to_any("allocateCapacity"))
        ]
        self._device.configure(props)

        # Test that the exception occurs as expected
        capacity = [
            CF.DataType(id="DCE:5636c210-0346-4df7-a5a3-8fd34c5540a8",
                        value=any.to_any(0))
        ]
        self.assertRaises(CORBA.UNKNOWN, self._device.allocateCapacity,
                          capacity)

        # Create an application that uses capacity; it's fine if it fails, but it shouldn't
        # kill the DomainManager.
        self._domMgr.installApplication(
            "/waveforms/CapacityUsage/CapacityUsage.sad.xml")
        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        appFact = self._domMgr._get_applicationFactories()[0]
        try:
            app = appFact.create(appFact._get_identifier(), [], [])
            self.fail(
                "Application creation should have failed due to failed allocation"
            )
        except CF.ApplicationFactory.CreateApplicationError:
            pass
        except:
            self.fail("Unhandled error in application creation")
    def test_QueryBadValue(self):
        """
        Tests that invalid values in Python components do not break query()
        """
        self.assertNotEqual(self._domMgr, None, "DomainManager not available")
        self.assertNotEqual(self._devMgr, None, "DeviceManager not available")

        self._app = self._launchApp('TestPythonProps')
        self.assertNotEqual(self._app, None, "Application not created")

        pre_props = self._app.query([])

        # Set the internal variable to an invalid value
        # NB: In the future, we may disallow the ability to set properties from
        #     invalid values; this test will need to be updated
        self._app.configure([CF.DataType('test_float', any.to_any('bad string'))])

        # Try querying the broken property to check that the query doesn't
        # throw an unexpected exception
        self._app.query([CF.DataType('test_float', any.to_any(None))])

        # Try querying all properties to ensure that the invalid value does not
        # derail the entire query
        post_props = self._app.query([])
        self.assertEqual(len(pre_props), len(post_props))
    def test_TerminateFailUnexpectedException (self):
        self.preconditions()

        # Make the device throw a generic Python exception on terminate, which will become
        # a CORBA::UNKNOWN to the DomainManager
        props = [CF.DataType(id="DCE:58f5720f-3a33-4056-8359-6b560613815d", value=any.to_any("terminate"))]
        self._device.configure(props)

        # Test that the exception occurs as expected
        self.assertRaises(CORBA.UNKNOWN, self._device.terminate, 0)

        # Create an application.
        self._domMgr.installApplication("/waveforms/CapacityUsage/CapacityUsage.sad.xml")
        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        appFact = self._domMgr._get_applicationFactories()[0]
        app = appFact.create(appFact._get_identifier(), [], [])

        # Get the component pid, then release the app; the component will be orphaned
        # but the release should succeed, restoring the device's capacity.
        pid = app._get_componentProcessIds()[0].processId
        app.releaseObject()

        # Restore the normal operation of terminate to kill the orphan.
        props = [CF.DataType(id="DCE:58f5720f-3a33-4056-8359-6b560613815d", value=any.to_any(""))]
        self._device.configure(props)
        self._device.terminate(pid)

        # Verify that the capacity has been returned to the device.
        prop = CF.DataType(id="DCE:5636c210-0346-4df7-a5a3-8fd34c5540a8", value=any.to_any(None))
        props = self._device.query([prop])
        self.assertEqual(props[0].value._v, 100000000)
 def testSRI(self):
     request = fe_types.frontend_tuner_allocation()
     upstream_sri = BULKIO.StreamSRI(hversion=1,
                                     xstart=0.0,
                                     xdelta=1 / 2e6,
                                     xunits=BULKIO.UNITS_TIME,
                                     subsize=0,
                                     ystart=0.0,
                                     ydelta=0.0,
                                     yunits=BULKIO.UNITS_NONE,
                                     mode=0,
                                     streamID="",
                                     blocking=False,
                                     keywords=[])
     request.center_frequency = 100e6
     request.bandwidth = 1e6
     request.sample_rate = 2e6
     cf = 100e6
     bw = 1e6
     _keywords = [
         CF.DataType(id="CHAN_RF", value=_any.to_any(cf)),
         CF.DataType(id="FRONTEND::BANDWIDTH", value=_any.to_any(bw))
     ]
     upstream_sri.keywords = _keywords
     self.assertTrue(
         tuner_device.validateRequestVsSRI(request, upstream_sri, False))
     cf = 100.49e6
     _keywords = [
         CF.DataType(id="CHAN_RF", value=_any.to_any(cf)),
         CF.DataType(id="FRONTEND::BANDWIDTH", value=_any.to_any(bw))
     ]
     upstream_sri.keywords = _keywords
     self.assertTrue(
         tuner_device.validateRequestVsSRI(request, upstream_sri, False))
     cf = 99.51e6
     _keywords = [
         CF.DataType(id="CHAN_RF", value=_any.to_any(cf)),
         CF.DataType(id="FRONTEND::BANDWIDTH", value=_any.to_any(bw))
     ]
     upstream_sri.keywords = _keywords
     self.assertTrue(
         tuner_device.validateRequestVsSRI(request, upstream_sri, False))
     cf = 100.51e6
     _keywords = [
         CF.DataType(id="CHAN_RF", value=_any.to_any(cf)),
         CF.DataType(id="FRONTEND::BANDWIDTH", value=_any.to_any(bw))
     ]
     upstream_sri.keywords = _keywords
     self.assertRaises(FRONTEND.BadParameterException,
                       tuner_device.validateRequestVsSRI, request,
                       upstream_sri, False)
     cf = 99.49e6
     _keywords = [
         CF.DataType(id="CHAN_RF", value=_any.to_any(cf)),
         CF.DataType(id="FRONTEND::BANDWIDTH", value=_any.to_any(bw))
     ]
     upstream_sri.keywords = _keywords
     self.assertRaises(FRONTEND.BadParameterException,
                       tuner_device.validateRequestVsSRI, request,
                       upstream_sri, False)
    def test_sequenceOperators (self):
        self.assertNotEqual(self._domMgr, None, "DomainManager not available")
        self.assertNotEqual(self._devMgr, None, "DeviceManager not available")

        self._app = self._launchApp('TestPythonProps')
        self.assertNotEqual(self._app, None, "Application not created")

        # Get the value for the structsequence property. The TestPyProps component
        # is also the assembly controller, so we can query it via the application.
        id = "DCE:897a5489-f680-46a8-a698-e36fd8bbae80"
        prop = self._app.query([CF.DataType(id + '[]', any.to_any(None))])[0]
        value = any.from_any(prop.value)

        # Test the length operator.
        length = self._app.query([CF.DataType(id + '[#]', any.to_any(None))])[0]
        length = any.from_any(length.value)
        self.assertEqual(len(value), length)

        # Test key list.
        keys = self._app.query([CF.DataType(id + '[?]', any.to_any(None))])[0]
        keys = any.from_any(keys.value)
        self.assertEqual(keys, range(length))

        # Test key-value pairs.
        kvpairs = self._app.query([CF.DataType(id + '[@]', any.to_any(None))])[0]
        kvpairs = any.from_any(kvpairs.value)
        for pair in kvpairs:
            index = int(pair['id'])
            self.assertEqual(value[index], pair['value'])

        # Test indexing.
        v1 = self._app.query([CF.DataType(id + '[1]', any.to_any(None))])[0]
        v1 = any.from_any(v1.value)
        self.assertEqual(len(v1), 1)
        self.assertEqual(v1[0], value[1])
Esempio n. 11
0
    def test_javaCompAware(self):
        if not java_support:
            return
        nodebooter, domMgr = self.launchDomainManager()
        self.assertNotEqual(domMgr, None)
        nodebooter, devMgr = self.launchDeviceManager(
            "/nodes/test_GPP_node/DeviceManager.dcd.xml")
        self.assertNotEqual(devMgr, None)

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

        initconfig = [
            CF.DataType(id=ExtendedCF.WKP.AWARE_APPLICATION,
                        value=any.to_any(True))
        ]

        app = appFact.create(appFact._get_name(), initconfig, [])
        self.assertEqual(len(domMgr._get_applications()), 1)
        app.start()
        time.sleep(0.5)
        app_id = app._get_registeredComponents()[0].componentObject.query(
            [CF.DataType(id='app_id', value=any.to_any(None))])[0].value._v
        dom_id = app._get_registeredComponents()[0].componentObject.query(
            [CF.DataType(id='dom_id', value=any.to_any(None))])[0].value._v
        self.assertEqual(app_id, app._get_identifier())
        self.assertEqual(dom_id, domMgr._get_identifier())
        self.assertEqual(app._get_aware(), True)
        app.releaseObject()
        self.assertEqual(len(domMgr._get_applications()), 0)
Esempio n. 12
0
    def test_pyCompBasic(self):
        nodebooter, domMgr = self.launchDomainManager()
        self.assertNotEqual(domMgr, None)
        nodebooter, devMgr = self.launchDeviceManager(
            "/nodes/test_GPP_node/DeviceManager.dcd.xml")
        self.assertNotEqual(devMgr, None)

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

        app = appFact.create(appFact._get_name(), [], [])
        self.assertEqual(len(domMgr._get_applications()), 1)
        app.start()
        time.sleep(0.5)
        app_id = app._get_registeredComponents()[0].componentObject.query(
            [CF.DataType(id='app_id', value=any.to_any(None))])[0].value._v
        number_components = app._get_registeredComponents(
        )[0].componentObject.query(
            [CF.DataType(id='number_components',
                         value=any.to_any(None))])[0].value._v
        dom_id = app._get_registeredComponents()[0].componentObject.query(
            [CF.DataType(id='dom_id', value=any.to_any(None))])[0].value._v
        self.assertEqual(app_id, app._get_identifier())
        self.assertEqual(number_components, 1)
        self.assertEqual(dom_id, domMgr._get_identifier())
        app.releaseObject()
        self.assertEqual(len(domMgr._get_applications()), 0)
Esempio n. 13
0
    def test_StructExternal(self):
        appFact = self.createAppFact("ExternalStruct")
        self._app = appFact.create(appFact._get_name(), [], [])
        self.assertNotEqual(self._app, None)

        # Make sure that the allocation was made to the device
        prop = CF.DataType(id="DCE:001fad60-b4b3-4ed2-94cb-40e1d956bf4f",
                           value=any.to_any(None))
        for dev in self._devMgr._get_registeredDevices():
            if dev._get_label() == 'BasicTestDevice1':
                allocRes = dev.query([prop])
        self.assertEquals(allocRes[0].value.value()[0].value.value(), 90)
        self.assertAlmostEquals(allocRes[0].value.value()[1].value.value(),
                                0.9)
        self.assertEquals(allocRes[0].value.value()[2].value.value()[0], 45)
        self.assertEquals(allocRes[0].value.value()[2].value.value()[1], 450)

        # Make sure values are deallocated on release
        self._app.releaseObject()
        self._app = None
        prop = CF.DataType(id="DCE:001fad60-b4b3-4ed2-94cb-40e1d956bf4f",
                           value=any.to_any(None))
        for dev in self._devMgr._get_registeredDevices():
            if dev._get_label() == 'BasicTestDevice1':
                allocRes = dev.query([prop])
        self.assertEquals(allocRes[0].value.value()[0].value.value(), 100)
        self.assertAlmostEquals(allocRes[0].value.value()[1].value.value(),
                                1.0)
        self.assertEquals(allocRes[0].value.value()[2].value.value()[0], 50)
        self.assertEquals(allocRes[0].value.value()[2].value.value()[1], 500)
    def testEraseKeyword(self):
        sri = bulkio.sri.create('erase_keyword')
        sri.keywords.append(CF.DataType('string', to_any('first')))
        sri.keywords.append(CF.DataType('number', to_any(2.0)))

        # Basic erase
        self.failUnless(bulkio.sri.hasKeyword(sri, 'string'))
        bulkio.sri.eraseKeyword(sri, 'string')
        self.assertEqual(1, len(sri.keywords))
        self.failIf(bulkio.sri.hasKeyword(sri, 'string'))
        self.failUnless(bulkio.sri.hasKeyword(sri, 'number'))

        # Non-existant key, no modification
        bulkio.sri.eraseKeyword(sri, 'missing')
        self.assertEqual(1, len(sri.keywords))
        self.failUnless(bulkio.sri.hasKeyword(sri, 'number'))

        # Add some more keywords, including a duplicate; erasing the duplicate
        # should only erase the first instance
        sri.keywords.append(CF.DataType('string', to_any('first')))
        sri.keywords.append(CF.DataType('number', to_any(500)))
        self.assertEqual(2.0, bulkio.sri.getKeyword(sri, 'number'))
        bulkio.sri.eraseKeyword(sri, 'number')
        self.assertEqual(2, len(sri.keywords))
        self.assertEqual(500, bulkio.sri.getKeyword(sri, 'number'))
    def test_pythonPropertyTypes (self):
        self.assertNotEqual(self._domMgr, None, "DomainManager not available")
        self.assertNotEqual(self._devMgr, None, "DeviceManager not available")

        self._app = self._launchApp("TestPythonPropsWithOverride")
        self.assertNotEqual(self._app, None, "Failed to launch app")

        # The TestPyProps component is also the assembly controller, so we can
        # query it via the application.
        props = self._app.query([CF.DataType("DCE:ffe634c9-096d-425b-86cc-df1cce50612f", any.to_any(None)),
                                CF.DataType("test_float", any.to_any(None)),
                                CF.DataType("test_double", any.to_any(None))])

        for prop in props:
            if prop.id == "DCE:ffe634c9-096d-425b-86cc-df1cce50612f":
                prop_struct = prop
            if prop.id == "test_float":
                prop_float = prop
            if prop.id == "test_double":
                prop_double = prop
        self.assertEqual(prop_float.value.typecode(), CORBA.TC_float)
        self.assertEqual(prop_double.value.typecode(), CORBA.TC_double)

        for sub in prop_struct.value._v:
            if sub.id == 'item4':
                sub_type_float = sub.value.typecode()
            if sub.id == 'item3':
                sub_type_double = sub.value.typecode()
        self.assertEqual(sub_type_float, CORBA.TC_float)
        self.assertEqual(sub_type_double, CORBA.TC_double)
    def test_externalAndACProp(self):
        self._createApp("")

        # Make sure external props that are in the AC can be accessed by either ID
        cppPropExt = CF.DataType(id="ext_prop_long",
                                 value=CORBA.Any(CORBA.TC_long, -11))
        cppPropQueryExt = CF.DataType(id="ext_prop_long",
                                      value=any.to_any(None))
        cppProp = CF.DataType(id="DCE:9d1e3621-27ca-4cd0-909d-90b7448b8f71",
                              value=CORBA.Any(CORBA.TC_long, -22))
        cppPropQuery = CF.DataType(
            id="DCE:9d1e3621-27ca-4cd0-909d-90b7448b8f71",
            value=any.to_any(None))

        self._app.configure([cppProp])
        self.assertEquals(
            self._app.query([cppPropQuery])[0].value.value(), -22)
        self.assertEquals(
            self._app.query([cppPropQueryExt])[0].value.value(), -22)

        self._app.configure([cppPropExt])
        self.assertEquals(
            self._app.query([cppPropQuery])[0].value.value(), -11)
        self.assertEquals(
            self._app.query([cppPropQueryExt])[0].value.value(), -11)
Esempio n. 17
0
    def launch(self, comp):
        # Pack the execparams into an array of string-valued properties
        properties = [
            CF.DataType(k, to_any(str(v)))
            for k, v in self._execparams.iteritems()
        ]
        # Pack the remaining props by having the component do the conversion
        properties.extend(
            comp._itemToDataType(k, v) for k, v in self._initProps.iteritems())
        properties.extend(
            comp._itemToDataType(k, v)
            for k, v in self._configProps.iteritems())

        # Tell the IDE to launch a specific implementation, if given
        if comp._impl is not None:
            properties.append(
                CF.DataType('__implementationID', to_any(comp._impl)))

        ref = comp._sandbox._createResource(comp._profile, comp._instanceName,
                                            properties)

        # The IDE sandbox API only allows us to specify the instance name, not
        # the identifier, so update by querying the component itself
        comp._refid = ref._get_identifier()

        return ref
    def test_LoadFailUnexpectedException (self):
        self.preconditions()

        # Make the device throw a generic Python exception on allocate, which will become
        # a CORBA::UNKNOWN to the DomainManager
        props = [CF.DataType(id="DCE:58f5720f-3a33-4056-8359-6b560613815d", value=any.to_any("load"))]
        self._device.configure(props)

        # Test that the exception occurs as expected
        self.assertRaises(CORBA.UNKNOWN, self._device.load, self._domMgr._get_fileMgr(), "/waveforms/CapacityUsage/CapacityUsage.sad.xml", CF.LoadableDevice.EXECUTABLE)

        # Try to create an application that uses capacity; it should fail,
        # but the failure should be handled gracefully and the device's
        # capacity should be restored.
        self._domMgr.installApplication("/waveforms/CapacityUsage/CapacityUsage.sad.xml")
        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        appFact = self._domMgr._get_applicationFactories()[0]
        try:
            app = appFact.create(appFact._get_identifier(), [], [])
            self.fail("Application should have failed due to exception")
        except CF.ApplicationFactory.CreateApplicationError:
            pass

        # Verify that the capacity has been returned to the device.
        prop = CF.DataType(id="DCE:5636c210-0346-4df7-a5a3-8fd34c5540a8", value=any.to_any(None))
        props = self._device.query([prop])
        self.assertEqual(props[0].value._v, 100000000)
Esempio n. 19
0
    def test_DeallocateFailUnexpectedException(self):
        self.preconditions()

        # Make the device throw a generic Python exception on deallocate, which will become
        # a CORBA::UNKNOWN to the DomainManager
        props = [
            CF.DataType(id="DCE:58f5720f-3a33-4056-8359-6b560613815d",
                        value=any.to_any("deallocateCapacity"))
        ]
        self._device.configure(props)

        # Test that the exception occurs as expected
        capacity = [
            CF.DataType(id="DCE:5636c210-0346-4df7-a5a3-8fd34c5540a8",
                        value=any.to_any(0))
        ]
        self.assertRaises(CORBA.UNKNOWN, self._device.deallocateCapacity,
                          capacity)

        # Create and release an application; the DomainManager should handle the exception
        # in stride.
        self._domMgr.installApplication(
            "/waveforms/CapacityUsage/CapacityUsage.sad.xml")
        self.assertEqual(len(self._domMgr._get_applicationFactories()), 1)
        appFact = self._domMgr._get_applicationFactories()[0]
        app = appFact.create(appFact._get_identifier(), [], [])
        app.releaseObject()
Esempio n. 20
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())
    def _testLoggingConfigURI(self, domLoggingConfigArg, devLoggingConfigArg):
        """A common function used to test various forms of the log4cxx URI."""
        if not domLoggingConfigArg:
            domLoggingConfigArg = ""
        domNB, domMgr = self.launchDomainManager(
            loggingURI=domLoggingConfigArg)
        self.assertNotEqual(domMgr, None)

        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")
        domLoggingConfigURI = result[0].value._v

        # Launch a device manager
        if not devLoggingConfigArg:
            devLoggingConfigArg = ""
        devNB, devMgr = self.launchDeviceManager(
            "/nodes/test_EmptyNode/DeviceManager.dcd.xml",
            loggingURI=devLoggingConfigArg)
        self.assertNotEqual(devMgr, None)

        prop = CF.DataType(id="LOGGING_CONFIG_URI", value=any.to_any(None))
        result = devMgr.query([prop])
        self.assertEqual(len(result), 1)
        self.assertEqual(result[0].id, "LOGGING_CONFIG_URI")
        devLoggingConfigURI = result[0].value._v

        return domLoggingConfigURI, devLoggingConfigURI
Esempio n. 22
0
 def initialize(self):
     self._log.debug("BasicUsesDevice.initialize()")
     # Initialize capacity properties
     self.props[getId("bandwidthCapacity")] = CF.DataType(
         id=getId("bandwidthCapacity"), value=any.to_any(100000000))
     self.props[getId("number_connections")] = CF.DataType(
         id=getId("number_connections"), value=any.to_any(0))
     self.toOther = toOther_i(self, "resource_out")
    def testHasKeyword(self):
        sri = bulkio.sri.create('has_keyword')
        sri.keywords.append(CF.DataType('string', to_any('first')))
        sri.keywords.append(CF.DataType('number', to_any(2.0)))

        self.failUnless(bulkio.sri.hasKeyword(sri, 'string'))
        self.failUnless(bulkio.sri.hasKeyword(sri, 'number'))
        self.failIf(bulkio.sri.hasKeyword(sri, 'missing'))
Esempio n. 24
0
 def query(self, configProperties):
     # If the list is empty, get all props
     if configProperties == []:
         return [CF.DataType(id=i, value=any.to_any(v)) for i,v in self.params.items()]
     else:
         result = []
         for p in configProperties:
             result.append(CF.DataType(id=p.id, value=any.to_any(self.parms[p.id])))
         return result
 def test_javaDevBasic(self):
     nodebooter, domMgr = self.launchDomainManager()
     self.assertNotEqual(domMgr, None)
     nodebooter, devMgr = self.launchDeviceManager("/nodes/java_dev_n/DeviceManager.dcd.xml")
     self.assertNotEqual(devMgr, None)
     devmgr_id = devMgr._get_registeredDevices()[0].query([CF.DataType(id='devmgr_id',value=any.to_any(None))])[0].value._v
     dom_id = devMgr._get_registeredDevices()[0].query([CF.DataType(id='dom_id',value=any.to_any(None))])[0].value._v
     self.assertEqual(devmgr_id, devMgr._get_identifier())
     self.assertEqual(dom_id, domMgr._get_identifier())
 def test_hexProperty(self):
     dev = self._devMgr._get_registeredDevices()[0]
     prop = CF.DataType(id='hex_props',value=any.to_any(None))
     results = dev.query([prop])
     self.assertEqual(any.from_any(results[0].value)[0], 2)
     self.assertEqual(any.from_any(results[0].value)[1], 3)
     prop = CF.DataType(id='hex_prop',value=any.to_any(None))
     results = dev.query([prop])
     self.assertEqual(any.from_any(results[0].value), 2)
Esempio n. 27
0
 def test_writeonly_py(self):
     simple = CF.DataType(id='foo', value=any.to_any(None))
     self.assertRaises(CF.UnknownProperties, self.dev.query, [simple])
     simple_seq = CF.DataType(id='foo_seq', value=any.to_any(None))
     self.assertRaises(CF.UnknownProperties, self.dev.query, [simple_seq])
     struct = CF.DataType(id='foo_struct', value=any.to_any(None))
     self.assertRaises(CF.UnknownProperties, self.dev.query, [struct])
     struct_seq = CF.DataType(id='foo_struct_seq', value=any.to_any(None))
     self.assertRaises(CF.UnknownProperties, self.dev.query, [struct_seq])
Esempio n. 28
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 test_readonly_sad(self):
        self.assertNotEqual(self._domain, None, "DomainManager not available")
        self.assertNotEqual(self._app, None, "Failed to launch app")

        props = self._app.query([CF.DataType("readOnly", any.to_any(None))])
        self.assertEqual(props[0].value._v, "set_once")

        # try and configure the component
        comp=filter( lambda c : c.name == 'TestJavaProps', self._app.comps )[0]
        self.assertNotEqual(comp,None)
        readonly_prop=CF.DataType("readOnly", any.to_any("try_again"))
        self.assertRaises(CF.PropertySet.InvalidConfiguration, comp.configure, [ readonly_prop ] )
    def test_AllocateRaiseUnexpectedException (self):
        devBooter_2, self._devMgr_2 = self.launchDeviceManager("/nodes/test_UnusableAllocateCapacity_node/DeviceManager.dcd.xml", debug=9)
        local_device = self._devMgr_2._get_registeredDevices()[0]

        # Cause a failure during the allocation process
        props = [CF.DataType(id="invalidCapacity", value=any.to_any(1000))]
        retval = local_device.allocateCapacity(props)
        self.assertEqual(retval, False)

        # Cause a failure during the allocation process
        props = [CF.DataType(id="configurationProperty", value=any.to_any(1000))]
        self.assertRaises(CF.Device.InvalidCapacity, local_device.allocateCapacity, props)