def test_AllocationPersistence(self): self.launchDeviceManager("/nodes/test_multiDomain_exec/DeviceManager.dcd.xml", domainManager=self._domainManager_1, debug=self.debuglevel) self.launchDeviceManager("/nodes/test_multiDomain_uses/DeviceManager.dcd.xml", domainManager=self._domainManager_2, debug=self.debuglevel) self._domainManager_1.registerRemoteDomainManager(self._domainManager_2) allocMgr_1 = self._domainManager_1._get_allocationMgr() # Make a couple of allocation requests that we know will have to be # split across the two domains execcap = {'DCE:8dcef419-b440-4bcf-b893-cab79b6024fb':1000, 'DCE:4f9a57fc-8fb3-47f6-b779-3c2692f52cf9':50.0} usescap = {'DCE:8cad8ca5-c155-4d1d-ae40-e194aa1d855f':1} requests = [_packageRequest('exec', properties.props_from_dict(execcap)), _packageRequest('uses', properties.props_from_dict(usescap))] results = dict((r.requestID, r) for r in allocMgr_1.allocate(requests)) self.assertEqual(len(requests), len(results)) usesId = results['uses'].allocationID execId = results['exec'].allocationID # Save the current allocation state pre = dict((al.allocationID, al) for al in allocMgr_1.allocations([])) # Kill the DomainManager os.kill(self._domainBooter_1.pid, signal.SIGTERM) if not self.waitTermination(self._domainBooter_1): self.fail("Domain Manager Failed to Die") # Re-launch and check that the allocation state remains the same self.launchDomainManager(endpoint='giop:tcp::5679', dbURI=self._dbfile, debug=self.debuglevel) post = dict((al.allocationID, al) for al in allocMgr_1.allocations([])) self.assertEqual(len(pre), len(post)) self.assertEqual(pre.keys(), post.keys()) for allocId, status in pre.iteritems(): self.assert_(_compareAllocations(status, post[allocId]))
def test_AllocationPersistence(self): self.launchDeviceManager( "/nodes/test_multiDomain_exec/DeviceManager.dcd.xml", domainManager=self._domainManager_1, debug=self.debuglevel) self.launchDeviceManager( "/nodes/test_multiDomain_uses/DeviceManager.dcd.xml", domainManager=self._domainManager_2, debug=self.debuglevel) self._domainManager_1.registerRemoteDomainManager( self._domainManager_2) allocMgr_1 = self._domainManager_1._get_allocationMgr() # Make a couple of allocation requests that we know will have to be # split across the two domains execcap = { 'DCE:8dcef419-b440-4bcf-b893-cab79b6024fb': 1000, 'DCE:4f9a57fc-8fb3-47f6-b779-3c2692f52cf9': 50.0 } usescap = {'DCE:8cad8ca5-c155-4d1d-ae40-e194aa1d855f': 1} requests = [ _packageRequest('exec', properties.props_from_dict(execcap)), _packageRequest('uses', properties.props_from_dict(usescap)) ] results = dict((r.requestID, r) for r in allocMgr_1.allocate(requests)) self.assertEqual(len(requests), len(results)) usesId = results['uses'].allocationID execId = results['exec'].allocationID # Save the current allocation state pre = dict((al.allocationID, al) for al in allocMgr_1.allocations([])) # Kill the DomainManager os.kill(self._domainBooter_1.pid, signal.SIGTERM) if not self.waitTermination(self._domainBooter_1): self.fail("Domain Manager Failed to Die") # Re-launch and check that the allocation state remains the same self.launchDomainManager(endpoint='giop:tcp::5679', dbURI=self._dbfile, debug=self.debuglevel) post = dict((al.allocationID, al) for al in allocMgr_1.allocations([])) self.assertEqual(len(pre), len(post)) self.assertEqual(pre.keys(), post.keys()) for allocId, status in pre.iteritems(): self.assert_(_compareAllocations(status, post[allocId]))
def test_RemoteAllocations(self): nb1, execDevNode1 = self.launchDeviceManager( "/nodes/test_multiDomain_exec/DeviceManager.dcd.xml", domainManager=self._domainManager_1, debug=self.debuglevel) nb2, basicDevNode1 = self.launchDeviceManager( "/nodes/test_multiDomain_uses/DeviceManager.dcd.xml", domainManager=self._domainManager_2, debug=self.debuglevel) # Register second domain with first (no need to do both directions) self._domainManager_1.registerRemoteDomainManager( self._domainManager_2) allocMgr_1 = self._domainManager_1._get_allocationMgr() allocMgr_2 = self._domainManager_2._get_allocationMgr() # Check that the initial state of all allocations is empty self.assertEqual(allocMgr_1.allocations([]), []) self.assertEqual(allocMgr_1.localAllocations([]), []) self.assertEqual(allocMgr_2.allocations([]), []) self.assertEqual(allocMgr_2.localAllocations([]), []) # Make a couple of allocation requests that we know will have to be # split across the two domains execcap = { 'DCE:8dcef419-b440-4bcf-b893-cab79b6024fb': 1000, 'DCE:4f9a57fc-8fb3-47f6-b779-3c2692f52cf9': 50.0 } usescap = {'DCE:8cad8ca5-c155-4d1d-ae40-e194aa1d855f': 1} requests = [ _packageRequest('exec', properties.props_from_dict(execcap)), _packageRequest('uses', properties.props_from_dict(usescap)) ] results = dict((r.requestID, r) for r in allocMgr_1.allocate(requests)) self.assertEqual(len(requests), len(results)) usesId = results['uses'].allocationID execId = results['exec'].allocationID # The first domain should report the full set of allocations, with only # the "exec" allocation showing up in the local allocations allocs = allocMgr_1.allocations([]) self.assertEqual(len(allocs), len(requests)) for status in allocs: if status.allocationID == usesId: resId = 'uses' elif status.allocationID == execId: resId = 'exec' else: self.fail('Unexpected allocation in results') self.assert_(_compareAllocations(status, results[resId])) # Try to retrieve a local and remote allocation via allocations allocs = allocMgr_1.allocations([execId]) self.assertEqual(len(allocs), 1) self.assert_(_compareAllocations(allocs[0], results['exec'])) allocs = allocMgr_1.allocations([usesId]) self.assertEqual(len(allocs), 1) self.assert_(_compareAllocations(allocs[0], results['uses'])) # Make sure we can retrieve the local allocation via localAllocations allocs = allocMgr_1.localAllocations([execId]) self.assertEqual(len(allocs), 1) self.assert_(_compareAllocations(allocs[0], results['exec'])) # Try to retrieve a remote allocation via localAllocations, and make # sure that the invalid ID causes an exception self.assertRaises(CF.AllocationManager.InvalidAllocationId, allocMgr_1.localAllocations, [usesId]) # Check the second domain, which should report just the 'uses' # allocation, but via both allocations and localAllocations allocs = allocMgr_2.allocations([]) self.assertEqual(len(allocs), 1) self.assert_(_compareAllocations(allocs[0], results['uses'])) allocs = allocMgr_2.localAllocations([]) self.assertEqual(len(allocs), 1) self.assert_(_compareAllocations(allocs[0], results['uses'])) # The second domain shouldn't know about the local 'exec' allocation self.assertRaises(CF.AllocationManager.InvalidAllocationId, allocMgr_2.allocations, [execId]) self.assertRaises(CF.AllocationManager.InvalidAllocationId, allocMgr_2.localAllocations, [execId]) # Deallocate the remote allocation and check that only the local 'exec' # allocation remains allocMgr_1.deallocate([usesId]) allocs = allocMgr_1.allocations([]) self.assertEqual(len(allocs), 1) self.assert_(_compareAllocations(allocs[0], results['exec'])) self.assertRaises(CF.AllocationManager.InvalidAllocationId, allocMgr_1.allocations, [usesId]) allocs = allocMgr_1.localAllocations([]) self.assertEqual(len(allocs), 1) self.assert_(_compareAllocations(allocs[0], results['exec'])) # The remote domain should have nothing left self.assertEqual(allocMgr_2.allocations([]), []) self.assertEqual(allocMgr_2.localAllocations([]), [])
def test_RemoteAllocations(self): nb1, execDevNode1 = self.launchDeviceManager("/nodes/test_multiDomain_exec/DeviceManager.dcd.xml", domainManager=self._domainManager_1, debug=self.debuglevel) nb2, basicDevNode1 = self.launchDeviceManager("/nodes/test_multiDomain_uses/DeviceManager.dcd.xml", domainManager=self._domainManager_2, debug=self.debuglevel) # Register second domain with first (no need to do both directions) self._domainManager_1.registerRemoteDomainManager(self._domainManager_2) allocMgr_1 = self._domainManager_1._get_allocationMgr() allocMgr_2 = self._domainManager_2._get_allocationMgr() # Check that the initial state of all allocations is empty self.assertEqual(allocMgr_1.allocations([]), []) self.assertEqual(allocMgr_1.localAllocations([]), []) self.assertEqual(allocMgr_2.allocations([]), []) self.assertEqual(allocMgr_2.localAllocations([]), []) # Make a couple of allocation requests that we know will have to be # split across the two domains execcap = {'DCE:8dcef419-b440-4bcf-b893-cab79b6024fb':1000, 'DCE:4f9a57fc-8fb3-47f6-b779-3c2692f52cf9':50.0} usescap = {'DCE:8cad8ca5-c155-4d1d-ae40-e194aa1d855f':1} requests = [_packageRequest('exec', properties.props_from_dict(execcap)), _packageRequest('uses', properties.props_from_dict(usescap))] results = dict((r.requestID, r) for r in allocMgr_1.allocate(requests)) self.assertEqual(len(requests), len(results)) usesId = results['uses'].allocationID execId = results['exec'].allocationID # The first domain should report the full set of allocations, with only # the "exec" allocation showing up in the local allocations allocs = allocMgr_1.allocations([]) self.assertEqual(len(allocs), len(requests)) for status in allocs: if status.allocationID == usesId: resId = 'uses' elif status.allocationID == execId: resId = 'exec' else: self.fail('Unexpected allocation in results') self.assert_(_compareAllocations(status, results[resId])) # Try to retrieve a local and remote allocation via allocations allocs = allocMgr_1.allocations([execId]) self.assertEqual(len(allocs), 1) self.assert_(_compareAllocations(allocs[0], results['exec'])) allocs = allocMgr_1.allocations([usesId]) self.assertEqual(len(allocs), 1) self.assert_(_compareAllocations(allocs[0], results['uses'])) # Make sure we can retrieve the local allocation via localAllocations allocs = allocMgr_1.localAllocations([execId]) self.assertEqual(len(allocs), 1) self.assert_(_compareAllocations(allocs[0], results['exec'])) # Try to retrieve a remote allocation via localAllocations, and make # sure that the invalid ID causes an exception self.assertRaises(CF.AllocationManager.InvalidAllocationId, allocMgr_1.localAllocations, [usesId]) # Check the second domain, which should report just the 'uses' # allocation, but via both allocations and localAllocations allocs = allocMgr_2.allocations([]) self.assertEqual(len(allocs), 1) self.assert_(_compareAllocations(allocs[0], results['uses'])) allocs = allocMgr_2.localAllocations([]) self.assertEqual(len(allocs), 1) self.assert_(_compareAllocations(allocs[0], results['uses'])) # The second domain shouldn't know about the local 'exec' allocation self.assertRaises(CF.AllocationManager.InvalidAllocationId, allocMgr_2.allocations, [execId]) self.assertRaises(CF.AllocationManager.InvalidAllocationId, allocMgr_2.localAllocations, [execId]) # Deallocate the remote allocation and check that only the local 'exec' # allocation remains allocMgr_1.deallocate([usesId]) allocs = allocMgr_1.allocations([]) self.assertEqual(len(allocs), 1) self.assert_(_compareAllocations(allocs[0], results['exec'])) self.assertRaises(CF.AllocationManager.InvalidAllocationId, allocMgr_1.allocations, [usesId]) allocs = allocMgr_1.localAllocations([]) self.assertEqual(len(allocs), 1) self.assert_(_compareAllocations(allocs[0], results['exec'])) # The remote domain should have nothing left self.assertEqual(allocMgr_2.allocations([]), []) self.assertEqual(allocMgr_2.localAllocations([]), [])