def test_AllocationManagerDevices(self): """ Test to verify that AllocationManagers report the correct devices for both localDevices() and allDevices(). """ nb1, execDevNode1 = self.launchDeviceManager( "/nodes/test_multiDomain_exec/DeviceManager.dcd.xml", domainManager=self._domainManager_1) self.assertNotEqual(execDevNode1, None) nb2, basicDevNode1 = self.launchDeviceManager( "/nodes/test_multiDomain_uses/DeviceManager.dcd.xml", domainManager=self._domainManager_2) self.assertNotEqual(basicDevNode1, None) # Retrieve the full list of devices in each domain devices_1 = allocMgrHelpers.parseDomainDevices(self._domainManager_1) devices_2 = allocMgrHelpers.parseDomainDevices(self._domainManager_2) # Combine both domains' devices devices = {} devices.update(devices_1) devices.update(devices_2) # Ensure that there are no duplicate IDs self.assertEqual(len(devices), len(devices_1) + len(devices_2)) # Connect the domains to each other self._domainManager_1.registerRemoteDomainManager( self._domainManager_2) allocMgr_1 = self._domainManager_1._get_allocationMgr() allocMgr_2 = self._domainManager_2._get_allocationMgr() # Check that the first AllocationManager's local devices exactly match # the devices found by walking through the domain local_1 = allocMgrHelpers.parseDeviceLocations( allocMgr_1._get_localDevices()) self.assertEqual(devices_1, local_1) # Check that all of the devices known to the first AllocationManager # matches the full set found by walking through the domains all_1 = allocMgrHelpers.parseDeviceLocations( allocMgr_1._get_allDevices()) self.assertEqual(devices, all_1) # The second domain is not linked back to the first, so its idea of # all devices should be the same as its local devices local_2 = allocMgrHelpers.parseDeviceLocations( allocMgr_2._get_localDevices()) self.assertEqual(devices_2, local_2) all_2 = allocMgrHelpers.parseDeviceLocations( allocMgr_2._get_allDevices()) self.assertEqual(local_2, all_2)
def test_redhawkutils_DeviceLists(self): """ Tests the operation of the device list attributes (allDevices, authorizedDevices, localDevices). """ # Keep adding nodes and testing the device lists to ensure that the # state is up-to-date devCount = 0 for node in ('test_collocation_good_node', 'test_SADUsesDevice', 'test_MultipleExecutableDevice_node'): nb, devMgr = self.launchDeviceManager('/nodes/'+node+'/DeviceManager.dcd.xml') # Collect the complete set of device IDs, making sure new devices # are added every time through the loop devices = allocMgrHelpers.parseDomainDevices(self._domMgr) self.assert_(len(devices) > devCount) devCount = len(devices) # Make sure localDevices matches our known state localDevices = allocMgrHelpers.parseDeviceLocations( self.am.localDevices ) self.assertEqual(devices, localDevices) # No policy is applied in default implementation, so authorized devices # should be the complete set of local devices authDevices = allocMgrHelpers.parseDeviceLocations( self.am.authorizedDevices ) self.assertEqual(devices, authDevices) # Make sure allDevices matches our known state; since there are no # remote domains, it should be the same as localDevices allDevices = allocMgrHelpers.parseDeviceLocations( self.am.allDevices) self.assertEqual(devices, allDevices)
def test_redhawkutils_DeviceLists(self): """ Tests the operation of the device list attributes (allDevices, authorizedDevices, localDevices). """ # Keep adding nodes and testing the device lists to ensure that the # state is up-to-date devCount = 0 for node in ('test_collocation_good_node', 'test_SADUsesDevice', 'test_MultipleExecutableDevice_node'): nb, devMgr = self.launchDeviceManager('/nodes/' + node + '/DeviceManager.dcd.xml') # Collect the complete set of device IDs, making sure new devices # are added every time through the loop devices = allocMgrHelpers.parseDomainDevices(self._domMgr) self.assert_(len(devices) > devCount) devCount = len(devices) # Make sure localDevices matches our known state localDevices = allocMgrHelpers.parseDeviceLocations( self.am.localDevices) self.assertEqual(devices, localDevices) # No policy is applied in default implementation, so authorized devices # should be the complete set of local devices authDevices = allocMgrHelpers.parseDeviceLocations( self.am.authorizedDevices) self.assertEqual(devices, authDevices) # Make sure allDevices matches our known state; since there are no # remote domains, it should be the same as localDevices allDevices = allocMgrHelpers.parseDeviceLocations( self.am.allDevices) self.assertEqual(devices, allDevices)
def test_DeviceIterators(self): """ Tests the operation of the device list iterators. """ nb, devMgr = self.launchDeviceManager('/nodes/test_MultipleExecutableDevice_node/DeviceManager.dcd.xml') devices = allocMgrHelpers.parseDomainDevices(self._domMgr) # First, try to list more devices than there are in the system, to make # sure no iterator is returned devlist, deviter = self._allocMgr.listDevices(CF.AllocationManager.LOCAL_DEVICES, 10) self.assertEqual(allocMgrHelpers.parseDeviceLocations(devlist), devices) self.assertEqual(deviter, None) # Next, start with fewer devices and fetch one-by-one via the iterator devlist, deviter = self._allocMgr.listDevices(CF.AllocationManager.LOCAL_DEVICES, 1) self.assertEqual(len(devlist), 1) self.assertNotEqual(deviter, None) try: # There has to be at least one more device status, item = deviter.next_one() self.assertTrue(status) self.assertNotEqual(item, None) devlist.append(item) # Fetch the remainder while status: status, item = deviter.next_one() if status: devlist.append(item) finally: deviter.destroy() # Check the resulting list self.assertEqual(allocMgrHelpers.parseDeviceLocations(devlist), devices) # Then try fetching by a higher count devlist, deviter = self._allocMgr.listDevices(CF.AllocationManager.LOCAL_DEVICES, 1) self.assertEqual(len(devlist), 1) self.assertNotEqual(deviter, None) try: # Try to fetch 2 more, which ought to succeed in full status, items = deviter.next_n(2) self.assertTrue(status) self.assertEqual(len(items), 2) devlist.extend(items) # Try 2 more, which should return only 1 status, items = deviter.next_n(2) self.assertTrue(status) self.assertEqual(len(items), 1) devlist.extend(items) # Finally, the next fetch should fail status, items = deviter.next_n(2) self.assertFalse(status) self.assertEqual(len(items), 0) finally: deviter.destroy() # Check the resulting list self.assertEqual(allocMgrHelpers.parseDeviceLocations(devlist), devices)
def test_AllocationManagerDevices(self): """ Test to verify that AllocationManagers report the correct devices for both localDevices() and allDevices(). """ nb1, execDevNode1 = self.launchDeviceManager("/nodes/test_multiDomain_exec/DeviceManager.dcd.xml", domainManager=self._domainManager_1) self.assertNotEqual(execDevNode1, None) nb2, basicDevNode1 = self.launchDeviceManager("/nodes/test_multiDomain_uses/DeviceManager.dcd.xml", domainManager=self._domainManager_2) self.assertNotEqual(basicDevNode1, None) # Retrieve the full list of devices in each domain devices_1 = allocMgrHelpers.parseDomainDevices(self._domainManager_1) devices_2 = allocMgrHelpers.parseDomainDevices(self._domainManager_2) # Combine both domains' devices devices = {} devices.update(devices_1) devices.update(devices_2) # Ensure that there are no duplicate IDs self.assertEqual(len(devices), len(devices_1)+len(devices_2)) # Connect the domains to each other self._domainManager_1.registerRemoteDomainManager(self._domainManager_2) allocMgr_1 = self._domainManager_1._get_allocationMgr() allocMgr_2 = self._domainManager_2._get_allocationMgr() # Check that the first AllocationManager's local devices exactly match # the devices found by walking through the domain local_1 = allocMgrHelpers.parseDeviceLocations(allocMgr_1._get_localDevices()) self.assertEqual(devices_1, local_1) # Check that all of the devices known to the first AllocationManager # matches the full set found by walking through the domains all_1 = allocMgrHelpers.parseDeviceLocations(allocMgr_1._get_allDevices()) self.assertEqual(devices, all_1) # The second domain is not linked back to the first, so its idea of # all devices should be the same as its local devices local_2 = allocMgrHelpers.parseDeviceLocations(allocMgr_2._get_localDevices()) self.assertEqual(devices_2, local_2) all_2 = allocMgrHelpers.parseDeviceLocations(allocMgr_2._get_allDevices()) self.assertEqual(local_2, all_2)