def test_AbsoluteFileURI(self): domLoggingConfigArg = os.path.join(scatest.getSdrPath(), "dom/mgr/logging.properties") devLoggingConfigArg = os.path.join(scatest.getSdrPath(), "dev/mgr/logging.properties") domLoggingConfigUri, devLoggingConfigUri = self._testLoggingConfigURI(domLoggingConfigArg, devLoggingConfigArg) expectedDomLoggingConfigUri = "file://" + os.path.join(scatest.getSdrPath(), "dom/mgr/logging.properties") expectedDevLoggingConfigUri = "file://" + os.path.join(scatest.getSdrPath(), "dev/mgr/logging.properties") self.assertEqual(domLoggingConfigUri, expectedDomLoggingConfigUri) self.assertEqual(devLoggingConfigUri, expectedDevLoggingConfigUri)
def test_nodeBooterShutdown(self): """Test that nodeBooter correctly cleans up. In OSSIE 0.7.4, and possibly before, killing a nodebooter that was running a device manager would prevent you from restarting the devicemanager without first restarting the domainmanager. Test that this condition is fixed""" # It is important that these core pieces somewhat work for all the other tests to succeed args = ["../../control/framework/nodeBooter","-D","-debug", "9","--nopersist" ] nb1= Popen( args, cwd=scatest.getSdrPath()) domainName = scatest.getTestDomainName() domMgr = self.waitDomainManager(scatest.getDomainMgrURI()) self.assertNotEqual(domMgr, None) self.assertEqual(len(domMgr._get_deviceManagers()), 0) args = ["../../control/framework/nodeBooter","-d","/nodes/test_ExecutableDevice_node/DeviceManager.dcd.xml", "--domainname", domainName ] nb2 = Popen( args, cwd=scatest.getSdrPath()) self.assertPredicateWithWait(lambda: len(domMgr._get_deviceManagers()) == 1) # Wait until the DeviceManager has finished launching its devices devMgr = domMgr._get_deviceManagers()[0] self.assertPredicateWithWait(lambda: len(devMgr._get_registeredDevices()) == 1) os.kill(nb2.pid, signal.SIGINT) self.assertPredicateWithWait(lambda: nb2.poll() != None) self.assertEqual(len(domMgr._get_deviceManagers()), 0) # Restart the device manager to prove that the shutdown was graceful. # In OSSIE 0.7.4 this would fail. args = ["../../control/framework/nodeBooter","-d","/nodes/test_ExecutableDevice_node/DeviceManager.dcd.xml", "--domainname", domainName ] nb3 = Popen(args, cwd=scatest.getSdrPath()) self.assertPredicateWithWait(lambda: len(domMgr._get_deviceManagers()) == 1) # Wait until the DeviceManager has finished launching its devices devMgr = domMgr._get_deviceManagers()[0] self.assertPredicateWithWait(lambda: len(devMgr._get_registeredDevices()) == 1) os.kill(nb3.pid, signal.SIGINT) self.assertPredicateWithWait(lambda: nb3.poll() != None) self.assertEqual(len(domMgr._get_deviceManagers()), 0) os.kill(nb1.pid, signal.SIGINT) self.assertPredicateWithWait(lambda: nb1.poll() != None) # Test that we cleaned up the name; this should be automatic because # the naming context should be empty. try: domMgr = self._root.resolve(scatest.getDomainMgrURI()) self.assertEqual(domMgr, None) except CosNaming.NamingContext.NotFound: pass # This exception is expected
def test_SimpleLaunch(self): os.environ['OSSIEHOME'] = 'foo' # Simulate RHComponentTestProgram testing.setSoftPkg(os.path.join(scatest.getSdrPath(), "dom", "components", "CommandWrapper", "CommandWrapper.spd.xml")) testing.setImplId("DCE:535a68a7-64e4-424b-9045-5ffc7659bf9d") testing.RHComponentTestCase.runTest = lambda : None tc = testing.RHComponentTestCase() tc.setUp() self.assertEqual(tc.comp_obj, None) self.assertEqual(tc.comp, None) tc.launch(ossiehome=os.getcwd()+'/../') pid = None comp_obj = None try: self.assertNotEqual(tc.comp_obj, None) self.assertNotEqual(tc.comp, None) comp_obj = tc.comp_obj self.assertEqual(comp_obj._non_existent(), False) self.assertEqual(comp_obj._is_a("IDL:CF/Resource:1.0"), True) finally: tc.tearDown() self.assertNotEqual(comp_obj, None) try: nonExistent = comp_obj._non_existent() except CORBA.TRANSIENT: nonExistent = True self.assertEqual(nonExistent, True) self.assertEqual(tc.comp_obj, None)
def test_nodeBooterDomainNameFromDMD(self): """Test that we read the correct domainname from the DMD file, the test domain should have been created by the test runner""" domainName = scatest.getTestDomainName() # Test that we don't already have a bound domain try: domMgr = self._root.resolve(scatest.getDomainMgrURI()) self.assertEqual(domMgr, None) except CosNaming.NamingContext.NotFound: pass # This exception is expected args = ["../../control/framework/nodeBooter","-D","-debug", "9","--nopersist" ] nb = Popen( args, cwd=scatest.getSdrPath()) domMgr = self.waitDomainManager(scatest.getDomainMgrURI()) self.assertNotEqual(domMgr, None) # Kill the nodebooter os.kill(nb.pid, signal.SIGINT) self.assertPredicateWithWait(lambda: nb.poll() == 0) # Test that we cleaned up the name; this should be automatic because # the naming context should be empty. try: domMgr = self._root.resolve(scatest.getDomainMgrURI()) self.assertEqual(domMgr, None) except CosNaming.NamingContext.NotFound: pass # This exception is expected
def 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))
def test_DeviceLaunchBackwardsCompatibility(self): # Simulate RHComponentTestProgram testing.setSoftPkg(os.path.join(scatest.getSdrPath(), "dev", "devices", "BasicTestDevice", "BasicTestDevice.spd.xml")) testing.setImplId("DCE:0ef71fab-731d-4ee1-a528-a6da2207e0c5") testing.ScaComponentTestCase.runTest = lambda : None tc = testing.ScaComponentTestCase() tc.setUp() self.assertEqual(tc.comp_obj, None) self.assertEqual(tc.comp, None) tc.launch(ossiehome=os.getcwd()+'/../') comp_obj = None try: self.assertNotEqual(tc.comp_obj, None) self.assertNotEqual(tc.comp, None) comp_obj = tc.comp_obj self.assertEqual(comp_obj._non_existent(), False) self.assertEqual(tc.comp_obj._is_a("IDL:CF/Resource:1.0"), True) self.assertEqual(tc.comp_obj._is_a("IDL:CF/Device:1.0"), True) self.assertEqual(tc.comp_obj._is_a("IDL:CF/LoadableDevice:1.0"), True) self.assertEqual(tc.comp_obj._is_a("IDL:CF/ExecutableDevice:1.0"), True) finally: tc.tearDown() self.assertNotEqual(comp_obj, None) try: nonExistent = comp_obj._non_existent() except CORBA.TRANSIENT: nonExistent = True self.assertEqual(nonExistent, True) self.assertEqual(tc.comp_obj, None)
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_GetPropertySet(self): testing.setSoftPkg(os.path.join(scatest.getSdrPath(), "dom", "components", "CommandWrapper", "CommandWrapper.spd.xml")) testing.setImplId("DCE:535a68a7-64e4-424b-9045-5ffc7659bf9d") testing.RHComponentTestCase.runTest = lambda : None tc = testing.RHComponentTestCase() tc.setUp() execparams = tc.getPropertySet(kinds=("execparam",), modes=("readwrite", "writeonly")) execparams = dict([(p.id, any.from_any(p.value)) for p in execparams]) self.assertEqual(execparams.has_key("EXEC_PARAM_1"), True) self.assertEqual(execparams.has_key("EXEC_PARAM_2"), True) self.assertEqual(execparams.has_key("EXEC_PARAM_4"), True) self.assertEqual(execparams.has_key("SOMEOBJREF"), True) self.assertEqual(execparams["EXEC_PARAM_1"], "Test1") self.assertEqual(execparams["EXEC_PARAM_2"], 2) self.assertEqual(execparams["EXEC_PARAM_4"], True) self.assertEqual(execparams["SOMEOBJREF"], None) execparams = tc.getPropertySet(kinds=("execparam",), modes=("readwrite", "writeonly"), includeNil=False) execparams = dict([(p.id, any.from_any(p.value)) for p in execparams]) self.assertEqual(execparams.has_key("EXEC_PARAM_1"), True) self.assertEqual(execparams.has_key("EXEC_PARAM_2"), True) self.assertEqual(execparams.has_key("EXEC_PARAM_4"), True) self.assertEqual(execparams.has_key("SOMEOBJREF"), False) self.assertEqual(execparams["EXEC_PARAM_1"], "Test1") self.assertEqual(execparams["EXEC_PARAM_2"], 2) self.assertEqual(execparams["EXEC_PARAM_4"], True) cfgparams = tc.getPropertySet(kinds=("configure",), modes=("readwrite", "writeonly")) cfgparams = dict([(p.id, any.from_any(p.value)) for p in cfgparams]) self.assertEqual(cfgparams.has_key("DCE:a4e7b230-1d17-4a86-aeff-ddc6ea3df26e"), True) self.assertEqual(cfgparams.has_key("DCE:5d8bfe8d-bc25-4f26-8144-248bc343aa53"), True) self.assertEqual(cfgparams.has_key("DCE:ffe634c9-096d-425b-86cc-df1cce50612f"), True) self.assertEqual(cfgparams.has_key("DCE:fa8c5924-845c-484a-81df-7941f2c5baa9"), True) self.assertEqual(cfgparams.has_key("DCE:a7de97ee-1e78-45e9-8e2b-204c141656fc"), True) self.assertEqual(cfgparams.has_key("DCE:9ec6e2ff-6a4f-4452-8f38-4df47d6eebc1"), True) self.assertEqual(cfgparams.has_key("DCE:cf623573-a09d-4fb1-a2ae-24b0b507115d"), True) self.assertEqual(cfgparams.has_key("DCE:6ad84383-49cf-4017-b7ca-0ec4c4917952"), True) propparams = tc.getPropertySet(kinds=("property",), modes=("readwrite", "writeonly")) propparams = dict([(p.id, any.from_any(p.value)) for p in propparams]) self.assertEqual(propparams.has_key("configure_prop_notset"), True) self.assertEqual(cfgparams["DCE:a4e7b230-1d17-4a86-aeff-ddc6ea3df26e"], "/bin/echo") self.assertEqual(cfgparams["DCE:5d8bfe8d-bc25-4f26-8144-248bc343aa53"], ["Hello World"]) self.assertEqual(cfgparams["DCE:ffe634c9-096d-425b-86cc-df1cce50612f"], [{"id": 'item1', 'value': 'value1'}, {"id": 'item2', 'value': 100}, {"id": 'item3', 'value': 3.14156} ]) self.assertEqual(cfgparams["DCE:fa8c5924-845c-484a-81df-7941f2c5baa9"], 10000) self.assertEqual(cfgparams["DCE:a7de97ee-1e78-45e9-8e2b-204c141656fc"], 12345678901) self.assertEqual(cfgparams["DCE:9ec6e2ff-6a4f-4452-8f38-4df47d6eebc1"], 11111111111) self.assertEqual(cfgparams["DCE:cf623573-a09d-4fb1-a2ae-24b0b507115d"], 500.0) self.assertEqual(cfgparams["DCE:6ad84383-49cf-4017-b7ca-0ec4c4917952"], None)
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_createApplicationFailures_recdep_bad_dir(self): wf_name=self.wf_name sadfile=self.sadfile dep_spd=scatest.getSdrPath()+"/dom/deps/cpp_dep2/cpp_dep2.spd.xml" shutil.copy( dep_spd+".TEST.bad.dir", dep_spd) self.assertRaises( CF.InvalidProfile, self._domMgr.createApplication, sadfile, "", [], []) ## reset file shutil.copy(dep_spd+".ORIG", dep_spd)
def test_installApplicationFailures_recdep_missing_file(self): wf_name=self.wf_name sadfile=self.sadfile dep_spd=scatest.getSdrPath()+"/dom/deps/cpp_dep2/cpp_dep2.spd.xml" shutil.move(dep_spd, dep_spd+".XXX") self.assertRaises( CF.DomainManager.ApplicationInstallationError, self._domMgr.installApplication, sadfile) ## reset file shutil.move(dep_spd+".XXX", dep_spd)
def test_createApplicationFailures_recdep_missing_file(self): wf_name=self.wf_name sadfile=self.sadfile dep_spd=scatest.getSdrPath()+"/dom/deps/cpp_dep2/cpp_dep2.spd.xml" shutil.move(dep_spd, dep_spd+".XXX") self.assertRaises( CF.InvalidProfile, self._domMgr.createApplication, sadfile, "", [], []) ## reset file shutil.move(dep_spd+".XXX", dep_spd)
def test_createApplicationFailures_comp_bad_dep_ref(self): wf_name=self.wf_name sadfile=self.sadfile comp_spd=scatest.getSdrPath()+"/dom/components/cpp_with_deps/cpp_with_deps.spd.xml" shutil.copy(comp_spd+".TEST.bad.dep", comp_spd) self.assertRaises( CF.InvalidProfile, self._domMgr.createApplication, sadfile, "", [], []) ## reset file shutil.copy(comp_spd+".ORIG", comp_spd)
def test_installApplicationFailures_recdep_bad_dir(self): wf_name=self.wf_name sadfile=self.sadfile dep_spd=scatest.getSdrPath()+"/dom/deps/cpp_dep2/cpp_dep2.spd.xml" shutil.copy( dep_spd+".TEST.bad.dir", dep_spd) self.assertRaises( CF.DomainManager.ApplicationInstallationError, self._domMgr.installApplication, sadfile) ## reset file shutil.copy(dep_spd+".ORIG", dep_spd)
def test_installApplicationFailures_comp_bad_dep_ref(self): wf_name=self.wf_name sadfile=self.sadfile comp_spd=scatest.getSdrPath()+"/dom/components/cpp_with_deps/cpp_with_deps.spd.xml" shutil.copy(comp_spd+".TEST.bad.dep", comp_spd) self.assertRaises( CF.DomainManager.ApplicationInstallationError, self._domMgr.installApplication, sadfile) ## reset file shutil.copy(comp_spd+".ORIG", comp_spd)
def test_createApplicationFailures_dep_missing_dep_dir(self): wf_name=self.wf_name sadfile=self.sadfile dep_dir=scatest.getSdrPath()+"/dom/deps/cpp_dep1/cpp" shutil.move(dep_dir, dep_dir+".XXX") self.assertRaises( CF.InvalidProfile, self._domMgr.createApplication, sadfile, "", [], []) ## reset file shutil.move( dep_dir+".XXX", dep_dir)
def test_Move(self): ################# # test move ################# self.assertNotEqual(self._domMgr, None) fileMgr = self._domMgr._get_fileMgr() # Test move on the same file system original = os.path.join(scatest.getSdrPath(), "dom/mgr/DomainManager.spd.xml") domoldfile = "/components/old.txt" domnewfile = "/waveforms/new.txt" devfile = "/ExecutableDevice_node/nodes/dev.txt" domlocaloldfile = os.path.join(scatest.getSdrPath(), 'dom' + domoldfile) domlocalnewfile = os.path.join(scatest.getSdrPath(), 'dom' + domnewfile) devlocalfile = os.path.join(scatest.getSdrPath(), "dev/nodes/dev.txt") shutil.copyfile(original, domlocaloldfile) if os.path.exists(domlocalnewfile): os.remove(domlocalnewfile) try: fileMgr.move(domoldfile, domnewfile) except: self.fail("Exception in local move") self.assertEqual(fileMgr.exists(domoldfile), False) self.assertEqual(fileMgr.exists(domnewfile), True) self.assertEqual(file(original).read(), file(domlocalnewfile).read()) # Test move across file systems if os.path.exists(devlocalfile): os.remove(devlocalfile) try: fileMgr.move(domnewfile, devfile) except: self.fail("Exception in local->remote move") self.assertEqual(fileMgr.exists(domnewfile), False) self.assertEqual(fileMgr.exists(devfile), True) self.assertEqual(file(original).read(), file(devlocalfile).read()) os.remove(devlocalfile)
def test_installApplicationFailures_dep_bad_rec_dep_file(self): wf_name = self.wf_name sadfile = self.sadfile dep_spd = scatest.getSdrPath() + "/dom/deps/cpp_dep1/cpp_dep1.spd.xml" shutil.copy(dep_spd + ".TEST.bad.rec.dep.file", dep_spd) self.assertRaises(CF.DomainManager.ApplicationInstallationError, self._domMgr.installApplication, sadfile) ## reset file shutil.copy(dep_spd + ".ORIG", dep_spd)
def test_createApplicationFailures_sad_compref_file(self): wf_name=self.wf_name sadfile=self.sadfile ## copy bad compref test 1 to sad file wf_sad=scatest.getSdrPath()+"/dom"+sadfile shutil.copy( wf_sad+".TEST.bad.comp.file", wf_sad) self.assertRaises( CF.InvalidProfile, self._domMgr.createApplication, sadfile, "", [], []) ## reset sad file shutil.copy( wf_sad+".ORIG", wf_sad)
def test_installApplicationFailures_recdep_missing_file(self): wf_name = self.wf_name sadfile = self.sadfile dep_spd = scatest.getSdrPath() + "/dom/deps/cpp_dep2/cpp_dep2.spd.xml" shutil.move(dep_spd, dep_spd + ".XXX") self.assertRaises(CF.DomainManager.ApplicationInstallationError, self._domMgr.installApplication, sadfile) ## reset file shutil.move(dep_spd + ".XXX", dep_spd)
def test_installApplicationFailures_sad_compref_test2(self): wf_name=self.wf_name sadfile=self.sadfile ## copy bad compref test 1 to sad file wf_sad=scatest.getSdrPath()+"/dom"+sadfile shutil.copy( wf_sad+".TEST.bad.comp.file", wf_sad) self.assertRaises( CF.DomainManager.ApplicationInstallationError, self._domMgr.installApplication, sadfile) ## reset sad file shutil.copy( wf_sad+".ORIG", wf_sad)
def test_DomainManagerId(self): self.assertNotEqual(self._domMgr, None) # Load the ID from the XML file dom = minidom.parse(os.path.join(scatest.getSdrPath(), "dom/domain/DomainManager.dmd.xml")) expectedId = dom.getElementsByTagName("domainmanagerconfiguration")[0].getAttribute("id") providedId = self._domMgr._get_identifier() self.assertEqual(providedId, expectedId, msg="Violation of SR:213 and/or SR:214") # According to SCA section D.8.1, the id is supposed to be a DCE UUID self.assertIsDceUUID(expectedId, msg="Violation of SCA D.8.1")
def test_createApplicationFailures_recdep_bad_dir(self): wf_name = self.wf_name sadfile = self.sadfile dep_spd = scatest.getSdrPath() + "/dom/deps/cpp_dep2/cpp_dep2.spd.xml" shutil.copy(dep_spd + ".TEST.bad.dir", dep_spd) self.assertRaises(CF.InvalidProfile, self._domMgr.createApplication, sadfile, "", [], []) ## reset file shutil.copy(dep_spd + ".ORIG", dep_spd)
def test_createApplicationFailures_dep_missing_dep_dir(self): wf_name = self.wf_name sadfile = self.sadfile dep_dir = scatest.getSdrPath() + "/dom/deps/cpp_dep1/cpp" shutil.move(dep_dir, dep_dir + ".XXX") self.assertRaises(CF.InvalidProfile, self._domMgr.createApplication, sadfile, "", [], []) ## reset file shutil.move(dep_dir + ".XXX", dep_dir)
def test_createApplicationFailures_recdep_missing_file(self): wf_name = self.wf_name sadfile = self.sadfile dep_spd = scatest.getSdrPath() + "/dom/deps/cpp_dep2/cpp_dep2.spd.xml" shutil.move(dep_spd, dep_spd + ".XXX") self.assertRaises(CF.InvalidProfile, self._domMgr.createApplication, sadfile, "", [], []) ## reset file shutil.move(dep_spd + ".XXX", dep_spd)
def test_installApplicationFailures_recdep_bad_dir(self): wf_name=self.wf_name sadfile=self.sadfile dep_spd=scatest.getSdrPath()+"/dom/deps/cpp_dep2/cpp_dep2.spd.xml" shutil.copy( dep_spd+".TEST.bad.dir", dep_spd) # code's localfile not checked during install self._domMgr.installApplication(sadfile) ## reset file shutil.copy(dep_spd+".ORIG", dep_spd)
def test_createApplication_recdep_typeisnoncompliant(self): wf_name = "cpp_deps_wf2" sadfile = "/waveforms/" + wf_name + "/" + wf_name + ".sad.xml" dep_spd = scatest.getSdrPath() + "/dom/deps/cpp_dep2/cpp_dep2.spd.xml" shutil.copy(dep_spd + ".NON_COMP", dep_spd) app = self._domMgr.createApplication(sadfile, "some_app", [], []) self.assertNotEqual(app, None) app.releaseObject() ## reset file shutil.copy(dep_spd + ".ORIG", dep_spd)
def test_createApplication_recdep_typeisnoncompliant(self): wf_name="cpp_deps_wf2" sadfile="/waveforms/"+wf_name+"/"+wf_name+".sad.xml" dep_spd=scatest.getSdrPath()+"/dom/deps/cpp_dep2/cpp_dep2.spd.xml" shutil.copy( dep_spd+".NON_COMP", dep_spd) app = self._domMgr.createApplication( sadfile, "some_app", [], []) self.assertNotEqual( app, None ) app.releaseObject() ## reset file shutil.copy(dep_spd+".ORIG", dep_spd)
def test_installApplicationFailures_comp_bad_dep_ref(self): wf_name = self.wf_name sadfile = self.sadfile comp_spd = scatest.getSdrPath( ) + "/dom/components/cpp_with_deps/cpp_with_deps.spd.xml" shutil.copy(comp_spd + ".TEST.bad.dep", comp_spd) self.assertRaises(CF.DomainManager.ApplicationInstallationError, self._domMgr.installApplication, sadfile) ## reset file shutil.copy(comp_spd + ".ORIG", comp_spd)
def test_createApplicationFailures_comp_bad_dep_ref(self): wf_name = self.wf_name sadfile = self.sadfile comp_spd = scatest.getSdrPath( ) + "/dom/components/cpp_with_deps/cpp_with_deps.spd.xml" shutil.copy(comp_spd + ".TEST.bad.dep", comp_spd) self.assertRaises(CF.InvalidProfile, self._domMgr.createApplication, sadfile, "", [], []) ## reset file shutil.copy(comp_spd + ".ORIG", comp_spd)
def test_installApplicationFailures_dep_missing(self): wf_name=self.wf_name sadfile=self.sadfile dep_dir=scatest.getSdrPath()+"/dom/deps/cpp_dep1" self.dep_dir = dep_dir shutil.move(dep_dir, dep_dir+".XXX") self.assertRaises( CF.DomainManager.ApplicationInstallationError, self._domMgr.installApplication, sadfile) ## reset file shutil.move(dep_dir+".XXX", dep_dir) self.dep_dir = None
def test_GetPropertySet(self): testing.setSoftPkg(os.path.join(scatest.getSdrPath(), "dom", "components", "CommandWrapper", "CommandWrapper.spd.xml")) testing.setImplId("DCE:535a68a7-64e4-424b-9045-5ffc7659bf9d") testing.ScaComponentTestCase.runTest = lambda : None tc = testing.ScaComponentTestCase() tc.setUp() execparams = tc.getPropertySet(kinds=("execparam",), modes=("readwrite", "writeonly")) execparams = dict([(p.id, any.from_any(p.value)) for p in execparams]) self.assertEqual(execparams.has_key("EXEC_PARAM_1"), True) self.assertEqual(execparams.has_key("EXEC_PARAM_2"), True) self.assertEqual(execparams.has_key("EXEC_PARAM_4"), True) self.assertEqual(execparams.has_key("SOMEOBJREF"), True) self.assertEqual(execparams["EXEC_PARAM_1"], "Test1") self.assertEqual(execparams["EXEC_PARAM_2"], 2) self.assertEqual(execparams["EXEC_PARAM_4"], True) self.assertEqual(execparams["SOMEOBJREF"], None) execparams = tc.getPropertySet(kinds=("execparam",), modes=("readwrite", "writeonly"), includeNil=False) execparams = dict([(p.id, any.from_any(p.value)) for p in execparams]) self.assertEqual(execparams.has_key("EXEC_PARAM_1"), True) self.assertEqual(execparams.has_key("EXEC_PARAM_2"), True) self.assertEqual(execparams.has_key("EXEC_PARAM_4"), True) self.assertEqual(execparams.has_key("SOMEOBJREF"), False) self.assertEqual(execparams["EXEC_PARAM_1"], "Test1") self.assertEqual(execparams["EXEC_PARAM_2"], 2) self.assertEqual(execparams["EXEC_PARAM_4"], True) cfgparams = tc.getPropertySet(kinds=("configure",), modes=("readwrite", "writeonly")) cfgparams = dict([(p.id, any.from_any(p.value)) for p in cfgparams]) self.assertEqual(cfgparams.has_key("DCE:a4e7b230-1d17-4a86-aeff-ddc6ea3df26e"), True) self.assertEqual(cfgparams.has_key("DCE:5d8bfe8d-bc25-4f26-8144-248bc343aa53"), True) self.assertEqual(cfgparams.has_key("DCE:ffe634c9-096d-425b-86cc-df1cce50612f"), True) self.assertEqual(cfgparams.has_key("DCE:fa8c5924-845c-484a-81df-7941f2c5baa9"), True) self.assertEqual(cfgparams.has_key("DCE:a7de97ee-1e78-45e9-8e2b-204c141656fc"), True) self.assertEqual(cfgparams.has_key("DCE:9ec6e2ff-6a4f-4452-8f38-4df47d6eebc1"), True) self.assertEqual(cfgparams.has_key("DCE:cf623573-a09d-4fb1-a2ae-24b0b507115d"), True) self.assertEqual(cfgparams.has_key("DCE:6ad84383-49cf-4017-b7ca-0ec4c4917952"), True) self.assertEqual(cfgparams["DCE:a4e7b230-1d17-4a86-aeff-ddc6ea3df26e"], "/bin/echo") self.assertEqual(cfgparams["DCE:5d8bfe8d-bc25-4f26-8144-248bc343aa53"], ["Hello World"]) self.assertEqual(cfgparams["DCE:ffe634c9-096d-425b-86cc-df1cce50612f"], [{"id": 'item1', 'value': 'value1'}, {"id": 'item2', 'value': 100}, {"id": 'item3', 'value': 3.14156} ]) self.assertEqual(cfgparams["DCE:fa8c5924-845c-484a-81df-7941f2c5baa9"], 10000) self.assertEqual(cfgparams["DCE:a7de97ee-1e78-45e9-8e2b-204c141656fc"], 12345678901) self.assertEqual(cfgparams["DCE:9ec6e2ff-6a4f-4452-8f38-4df47d6eebc1"], 11111111111) self.assertEqual(cfgparams["DCE:cf623573-a09d-4fb1-a2ae-24b0b507115d"], 500.0) self.assertEqual(cfgparams["DCE:6ad84383-49cf-4017-b7ca-0ec4c4917952"], None)
def test_createApplicationFailures_comp_bad_scd_file(self): wf_name = self.wf_name sadfile = self.sadfile comp_spd = scatest.getSdrPath( ) + "/dom/components/cpp_with_deps/cpp_with_deps.spd.xml" shutil.copy(comp_spd + ".TEST.bad.scd", comp_spd) self.assertRaises( (CF.InvalidProfile, CF.DomainManager.ApplicationInstallationError), self._domMgr.createApplication, sadfile, "", [], []) ## reset file shutil.copy(comp_spd + ".ORIG", comp_spd)
def test_installApplication_recdep_typeisnoncompliant(self): wf_name="cpp_deps_wf2" sadfile="/waveforms/"+wf_name+"/"+wf_name+".sad.xml" dep_spd=scatest.getSdrPath()+"/dom/deps/cpp_dep2/cpp_dep2.spd.xml" shutil.copy( dep_spd+".NON_COMP", dep_spd) self._domMgr.installApplication( sadfile ) appFact = self._domMgr._get_applicationFactories()[0] self.assertNotEqual( appFact, None ) self._domMgr.uninstallApplication(appFact._get_identifier()) ## reset file shutil.copy(dep_spd+".ORIG", dep_spd)
def test_installApplicationFailures_dep_missing_dep_dir(self): wf_name=self.wf_name sadfile=self.sadfile dep_dir=scatest.getSdrPath()+"/dom/deps/cpp_dep1/cpp" self.dep_dir=dep_dir shutil.move(dep_dir, dep_dir+".XXX") # should work refers to code's localfile self._domMgr.installApplication(sadfile) ## reset file shutil.move( dep_dir+".XXX", dep_dir) self.dep_dir=None
def test_createApplicationFailures_sad_compref_refid(self): wf_name = self.wf_name sadfile = self.sadfile ## copy bad compref test 1 to sad filex wf_sad = scatest.getSdrPath() + "/dom" + sadfile shutil.copy(wf_sad + ".TEST.bad.compref", wf_sad) self.assertRaises( (CF.InvalidProfile, CF.DomainManager.ApplicationInstallationError), self._domMgr.createApplication, sadfile, "", [], []) ## reset sad file shutil.copy(wf_sad + ".ORIG", wf_sad)
def test_installApplication_recdep_typeisnoncompliant(self): wf_name = "cpp_deps_wf2" sadfile = "/waveforms/" + wf_name + "/" + wf_name + ".sad.xml" dep_spd = scatest.getSdrPath() + "/dom/deps/cpp_dep2/cpp_dep2.spd.xml" shutil.copy(dep_spd + ".NON_COMP", dep_spd) self._domMgr.installApplication(sadfile) appFact = self._domMgr._get_applicationFactories()[0] self.assertNotEqual(appFact, None) self._domMgr.uninstallApplication(appFact._get_identifier()) ## reset file shutil.copy(dep_spd + ".ORIG", dep_spd)
def test_installApplicationFailures_comp_missing3(self): wf_name=self.wf_name sadfile=self.sadfile ## remove component spd file comp_prf=scatest.getSdrPath()+"/dom/components/cpp_with_deps/cpp_with_deps.prf.xml" try: os.remove(comp_prf) except: pass self.assertRaises( CF.DomainManager.ApplicationInstallationError, self._domMgr.installApplication, sadfile) ## reset file shutil.copy(comp_prf+".ORIG", comp_prf)
def test_createApplicationFailures_comp_missing3(self): wf_name=self.wf_name sadfile=self.sadfile ## remove component spd file comp_prf=scatest.getSdrPath()+"/dom/components/cpp_with_deps/cpp_with_deps.prf.xml" try: os.remove(comp_prf) except: pass self.assertRaises( CF.InvalidProfile, self._domMgr.createApplication, sadfile, "", [], []) ## reset file shutil.copy(comp_prf+".ORIG", comp_prf)
def test_createApplicationFailures_recdep_missing_file(self): wf_name = self.wf_name sadfile = self.sadfile dep_spd = scatest.getSdrPath() + "/dom/deps/cpp_dep2/cpp_dep2.spd.xml" self.dep_dir = dep_spd shutil.move(dep_spd, dep_spd + ".XXX") self.assertRaises( (CF.InvalidProfile, CF.DomainManager.ApplicationInstallationError), self._domMgr.createApplication, sadfile, "", [], []) ## reset file shutil.move(dep_spd + ".XXX", dep_spd) self.dep_dir = None
def test_Sad_CompProps_LogCfg_Debug(self): # Double check the DomainManager LOGGING_CONFIG_URI prop = CF.DataType(id="LOGGING_CONFIG_URI", value=any.to_any(None)) result = self._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) app = self._rhDom.createApplication( '/waveforms/loggingconfig/TestCpp/TestCpp_props_debug.sad.xml') comp = app.comps[0] self.assertNotEqual(comp, None) # get command line arguments for proc self.getProcessLogArgs('components/C2') expect_logcfg = "sca://logcfg/log.props.c2" self.assertNotEqual(self.logcfg_uri, None) self.assertEqual(self.logcfg_uri.split("?fs=")[0], expect_logcfg) execparamObj = self._orb.string_to_object( self.logcfg_uri.split("?fs=")[1]) # Need to compare actual objects since the IOR strings could potentially differ for the same object self.assert_(self._domMgr._get_fileMgr()._is_equivalent(execparamObj)) self.assertEqual(self.debug_level, "5") app.releaseObject() app_1 = self._rhDom.createApplication( '/waveforms/loggingconfig/TestCpp/TestCpp_props_debug.sad.xml', initConfiguration={ "LOGGING_CONFIG_URI": "sca:///mgr/logging.properties" }) comp = app.comps[0] self.assertNotEqual(comp, None) # get command line arguments for proc self.getProcessLogArgs('components/C2') expect_logcfg = "sca:///mgr/logging.properties" self.assertNotEqual(self.logcfg_uri, None) self.assertEqual(self.logcfg_uri.split("?fs=")[0], expect_logcfg) execparamObj = self._orb.string_to_object( self.logcfg_uri.split("?fs=")[1]) # Need to compare actual objects since the IOR strings could potentially differ for the same object self.assert_(self._domMgr._get_fileMgr()._is_equivalent(execparamObj)) self.assertEqual(self.debug_level, "5")
def test_DASAllocationFail(self): self._domMgr.installApplication("/waveforms/CapacityUsage/CapacityUsage.sad.xml") # Start the first DeviceManager nb1, node1 = self.launchDeviceManager("/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml", debug=self.debuglevel) # Ensure the expected device is available self.assertNotEqual(node1, None) self.assertEqual(len(node1._get_registeredDevices()), 1) device1 = node1._get_registeredDevices()[0] self.assertEqual(self._getBogoMips(device1), 100000000) appFact = self._domMgr._get_applicationFactories()[0] # load the device assignment sequence das = minidom.parse(os.path.join(scatest.getSdrPath(), "dom/waveforms/CapacityUsage/CapacityUsage_DAS.xml")) ds = [] deviceAssignmentTypeNodeList = das.getElementsByTagName("deviceassignmenttype") for node in deviceAssignmentTypeNodeList: componentid = node.getElementsByTagName("componentid")[0].firstChild.data assigndeviceid = node.getElementsByTagName("assigndeviceid")[0].firstChild.data ds.append( CF.DeviceAssignmentType(str(componentid),str(assigndeviceid)) ) # Create two applications to take up the capacity of the first device # first on uses DAS app1 = appFact.create(appFact._get_name(), [], ds) self.assertEqual(self._getBogoMips(device1), 50000000) # second one is sans DAS app2 = appFact.create(appFact._get_name(), [], []) self.assertEqual(self._getBogoMips(device1), 0) # Try to create another app, which should fail due to lack of capacity. # doing this with DAS since it exercises a different piece of code try: failApp = appFact.create(appFact._get_name(), [], ds) failApp.releaseObject() self.fail("Created application with no capacity") except: pass app2.releaseObject() self.assertEqual(self._getBogoMips(device1), 50000000) app1.releaseObject() self.assertEqual(self._getBogoMips(device1), 100000000) self._domMgr.uninstallApplication(appFact._get_identifier())
def test_DASAllocationFail(self): self._domMgr.installApplication("/waveforms/CapacityUsage/CapacityUsage.sad.xml") # Start the first DeviceManager nb1, node1 = self.launchDeviceManager("/nodes/test_BasicTestDevice_node/DeviceManager.dcd.xml") # Ensure the expected device is available self.assertNotEqual(node1, None) scatest.verifyDeviceLaunch(self, node1, 1) device1 = node1._get_registeredDevices()[0] self.assertEqual(self._getBogoMips(device1), 100000000) appFact = self._domMgr._get_applicationFactories()[0] # load the device assignment sequence das = minidom.parse(os.path.join(scatest.getSdrPath(), "dom/waveforms/CapacityUsage/CapacityUsage_DAS.xml")) ds = [] deviceAssignmentTypeNodeList = das.getElementsByTagName("deviceassignmenttype") for node in deviceAssignmentTypeNodeList: componentid = node.getElementsByTagName("componentid")[0].firstChild.data assigndeviceid = node.getElementsByTagName("assigndeviceid")[0].firstChild.data ds.append( CF.DeviceAssignmentType(str(componentid),str(assigndeviceid)) ) # Create two applications to take up the capacity of the first device # first on uses DAS app1 = appFact.create(appFact._get_name(), [], ds) self.assertEqual(self._getBogoMips(device1), 50000000) # second one is sans DAS app2 = appFact.create(appFact._get_name(), [], []) self.assertEqual(self._getBogoMips(device1), 0) # Try to create another app, which should fail due to lack of capacity. # doing this with DAS since it exercises a different piece of code try: failApp = appFact.create(appFact._get_name(), [], ds) failApp.releaseObject() self.fail("Created application with no capacity") except: pass app2.releaseObject() self.assertEqual(self._getBogoMips(device1), 50000000) app1.releaseObject() self.assertEqual(self._getBogoMips(device1), 100000000) self._domMgr.uninstallApplication(appFact._get_identifier())
def test_cpp_DirectoryLoad(self): self.assertNotEqual(self._domMgr, None) # Verify in the devices cache is empty 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 _test_NoAccessDir(self, nodeName): devBooter, devMgr = self.launchDeviceManager("/nodes/%s/DeviceManager.dcd.xml" % nodeName) device = devMgr._get_registeredDevices()[0] fileMgr = self._domMgr._get_fileMgr() dirname = '/noaccess' testdir = os.path.join(scatest.getSdrPath(), 'dom' + dirname) if not os.path.exists(testdir): os.mkdir(testdir, 0000) else: os.chmod(testdir, 0000) try: self.assertFalse(os.access(testdir, os.R_OK|os.X_OK), 'Current user can still access directory') self.assertRaises(CF.LoadableDevice.LoadFail, device.load, fileMgr, dirname, CF.LoadableDevice.SHARED_LIBRARY) finally: os.rmdir(testdir)
def test_createApplicationFailures_comp_missing2(self): wf_name = self.wf_name sadfile = self.sadfile ## remove component spd file comp_scd = scatest.getSdrPath( ) + "/dom/components/cpp_with_deps/cpp_with_deps.scd.xml" try: os.remove(comp_scd) except: pass self.assertRaises( (CF.InvalidProfile, CF.DomainManager.ApplicationInstallationError), self._domMgr.createApplication, sadfile, "", [], []) ## reset file shutil.copy(comp_scd + ".ORIG", comp_scd)
def test_ExistsException(self): # Makes sure that FileSystem::exists() throws correct exception and # doesn't kill domain for files in directories it cannot access dirname = '/noaccess' testdir = os.path.join(scatest.getSdrPath(), 'dom' + dirname) if not os.path.exists(testdir): os.mkdir(testdir, 0644) else: os.chmod(testdir, 0644) self.assertNotEqual(self._domMgr, None) fileMgr = self._domMgr._get_fileMgr() try: self.assertRaises(CF.InvalidFileName, fileMgr.exists, os.path.join(dirname, 'testfile')) finally: os.rmdir(testdir)
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 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 scatest.verifyDeviceLaunch(self, devMgr, 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))
def test_DCD_LoggingConfig(self): # Double check the DomainManager LOGGING_CONFIG_URI prop = CF.DataType(id="LOGGING_CONFIG_URI", value=any.to_any(None)) result = self._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) # get command line arguments for process self.getProcessLogArgs('devices/BasicTestDevice') self.assertNotEqual(self.logcfg_uri,None) self.assertEqual(self.logcfg_uri.split("?fs=")[0], "sca:///logcfg/log.basic.props") execparamObj = self._orb.string_to_object(self.logcfg_uri.split("?fs=")[1]) # Need to compare actual objects since the IOR strings could potentially differ for the same object self.assert_(self._devMgr._get_fileSys()._is_equivalent(execparamObj)) self.assertEqual(self.debug_level,"2")
def test_DomainManagerApplicationLifecycle(self): self.assertNotEqual(self._domMgr, None) self.assertEqual(len(self._domMgr._get_applicationFactories()), 0) self.assertEqual(len(self._domMgr._get_applications()), 0) # This filename isn't in compliance with SCA, but it is necessary for OSSIE self._domMgr.installApplication("/waveforms/CommandWrapper/CommandWrapper.sad.xml") self.assertEqual(len(self._domMgr._get_applicationFactories()), 1) self.assertEqual(len(self._domMgr._get_applications()), 0) appFact = self._domMgr._get_applicationFactories()[0] dom = minidom.parse(os.path.join(scatest.getSdrPath(), "dom/waveforms/CommandWrapper/CommandWrapper.sad.xml")) expectedId = dom.getElementsByTagName("softwareassembly")[0].getAttribute("id") providedId = appFact._get_identifier() self.assertEqual(providedId, expectedId, msg="Violation of SR:155 and/or SR:156") expectedName = dom.getElementsByTagName("softwareassembly")[0].getAttribute("name") providedName = appFact._get_name() self.assertEqual(providedName, expectedName, msg="Violation of SR:153") self._domMgr.uninstallApplication(providedId) self.assertEqual(len(self._domMgr._get_applicationFactories()), 0) self.assertEqual(len(self._domMgr._get_applications()), 0)
if os.environ.has_key('OSSIEUNITTESTSLOGCONFIG'): ans = raw_input("OSSIEUNITTESTSLOGCONFIG already exists as %s. Do you want to continue [Y]/N? " % os.environ[OSSIEUNITTESTSLOGCONFIG]).upper() if ans == "N": sys.exit() else: os.environ['OSSIEUNITTESTSLOGCONFIG'] = os.path.abspath(options.logconfig) print "" print "Creating the Test Domain" print "" scatest.createTestDomain() print "" print "R U N N I N G T E S T S" print "SDRROOT: ", scatest.getSdrPath() print "" suite = TestCollector(files, testMethodPrefix=options.prefix, prompt=options.prompt) if options.xmlfile == None: runner = unittest.TextTestRunner(verbosity=options.verbosity) else: stream = open(options.xmlfile, "w") runner = xmlrunner.XMLTestRunner(stream) if options.debug: import pdb pdb.run("runner.run(suite)") else: runner.run(suite)
def setUp(self): self.devRoot = os.path.join(scatest.getSdrPath(), "dev")
def test_DirectoryOperation(self): ################# # test mkdir ################# self.assertNotEqual(self._domMgr, None) fileMgr = self._domMgr._get_fileMgr() domdir = '/mkdir_test_directory_tmp_local' localdomdir = 'dom/mkdir_test_directory_tmp_local' devdir = "/DeviceManager/mkdir_test_directory_tmp_mounted" localdevdir = "dev/mkdir_test_directory_tmp_mounted" domdir_nestedbase = '/mkdir_test_directory_tmp_nested1' localdomdir_nestedbase = 'dom/mkdir_test_directory_tmp_nested1' devdir_nestedbase = '/DeviceManager/mkdir_test_directory_tmp_nested1' localdevdir_nestedbase = 'dev/mkdir_test_directory_tmp_nested1' tmpdevfile = '/DeviceManager/mkdir_test_directory_tmp_nested1/foo.txt' tmpdevfilenested = '/DeviceManager/mkdir_test_directory_tmp_nested1/nested2/foo.txt' # test local mkdir if os.path.exists(os.path.join(scatest.getSdrPath(), localdomdir)): os.rmdir(os.path.join(scatest.getSdrPath(), localdomdir)) try: fileMgr.mkdir(domdir) except: self.fail("Something bad happened in fileMgr.mkdir(newdir_local)") self.assertEqual(fileMgr.exists(domdir), True) # test mounted mkdir if os.path.exists(os.path.join(scatest.getSdrPath(), localdevdir)): os.rmdir(os.path.join(scatest.getSdrPath(), localdevdir)) try: fileMgr.mkdir(devdir) except: self.fail("Something bad happened in fileMgr.mkdir(newdir_mounted)") self.assertEqual(fileMgr.exists(devdir), True) # test nested mkdir local if os.path.exists(os.path.join(scatest.getSdrPath(), localdomdir_nestedbase + '/nested2')): os.rmdir(os.path.join(scatest.getSdrPath(), localdomdir_nestedbase + '/nested2')) if os.path.exists(os.path.join(scatest.getSdrPath(), localdomdir_nestedbase)): os.rmdir(os.path.join(scatest.getSdrPath(), localdomdir_nestedbase)) try: fileMgr.mkdir(domdir_nestedbase + '/nested2') except: self.fail("Something bad happened in fileMgr.mkdir(domdir_nestedbase)") self.assertEqual(fileMgr.exists(domdir_nestedbase + '/nested2'), True) # test nested mkdir mounted # also test trailing '/' if os.path.exists(os.path.join(scatest.getSdrPath(), localdevdir_nestedbase + '/nested2')): os.rmdir(os.path.join(scatest.getSdrPath(), localdevdir_nestedbase + '/nested2')) if os.path.exists(os.path.join(scatest.getSdrPath(), localdevdir_nestedbase)): os.rmdir(os.path.join(scatest.getSdrPath(), localdevdir_nestedbase)) try: fileMgr.mkdir(devdir_nestedbase + '/nested2/') except: self.fail("Something bad happened in fileMgr.mkdir(devdir_nestedbase)") self.assertEqual(fileMgr.exists(devdir_nestedbase + '/nested2'), True) ################# # test rmdir ################# #remove empty directory try: fileMgr.rmdir(domdir) fileMgr.rmdir(devdir) except: self.fail("Something bad happened in fileMgr.rmdir()") self.assertEqual(fileMgr.exists(domdir), False) self.assertEqual(fileMgr.exists(devdir), False) #remove nested empty directories try: fileMgr.rmdir(domdir_nestedbase) except: self.fail("Something bad happened in fileMgr.rmdir(domdir_nestedbase)") self.assertEqual(fileMgr.exists(domdir_nestedbase + '/nested2'), False) self.assertEqual(fileMgr.exists(domdir_nestedbase), False) #make sure remove doesn't happen if files are in directory newfile = fileMgr.create(tmpdevfile) newfile.close() try: fileMgr.rmdir(devdir_nestedbase) self.fail("rmdir should not have worked. Directory not empty") except: self.assertEqual(fileMgr.exists(devdir_nestedbase + '/nested2'), True) fileMgr.remove(tmpdevfile) self.assertEqual(fileMgr.exists(tmpdevfile), False) #same thing as above, but in a nested directory newfile = fileMgr.create(tmpdevfilenested) newfile.close() try: fileMgr.rmdir(devdir_nestedbase) self.fail("rmdir should not have worked. Directory not empty") except: self.assertEqual(fileMgr.exists(devdir_nestedbase + '/nested2'), True) fileMgr.remove(tmpdevfilenested) self.assertEqual(fileMgr.exists(tmpdevfilenested), False) #remove the mounted nested directories try: fileMgr.rmdir(devdir_nestedbase) except: self.fail("Something bad happened in fileMgr.rmdir(devdir_nestedbase)") self.assertEqual(fileMgr.exists(devdir_nestedbase + '/nested2'), False) self.assertEqual(fileMgr.exists(devdir_nestedbase), False) # make sure error is thrown if trying to remove a directory that doesn't exists try: fileMgr.rmdir(domdir) self.fail("mdir should not have worked. Directory does not exist") except: self.assertEqual(fileMgr.exists(domdir), False)