def test__submitPilotsToQueue(self, _patch1, _patch2, _patch3, _patch4): """ Testing SiteDirector()._submitPilotsToQueue() """ sd = SiteDirector() sd.log = gLogger sd.am_getOption = mockAM sd.log.setLevel('DEBUG') sd.rpcMatcher = MagicMock() sd.rssClient = MagicMock() sd.workingDirectory = '' sd.queueDict = { 'aQueue': { 'Site': 'LCG.CERN.cern', 'CEName': 'aCE', 'CEType': 'SSH', 'QueueName': 'aQueue', 'ParametersDict': { 'CPUTime': 12345, 'Community': 'lhcb', 'OwnerGroup': ['lhcb_user'], 'Setup': 'LHCb-Production', 'Site': 'LCG.CERN.cern', 'SubmitPool': '' } } } sd.queueSlots = {'aQueue': {'AvailableSlots': 10}} res = sd._submitPilotsToQueue(1, MagicMock(), 'aQueue') self.assertTrue(res['OK']) self.assertEqual(res['Value'][0], 0)
def test__submitPilotsToQueue(mocker): """ Testing SiteDirector()._submitPilotsToQueue() """ mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule.__init__") mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.gConfig.getValue", side_effect=mockGCReply) mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.CSGlobals.getSetup", side_effect=mockCSGlobalReply) mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule", side_effect=mockAM) sd = SiteDirector() sd.log = gLogger sd.am_getOption = mockAM sd.log.setLevel('DEBUG') sd.rpcMatcher = MagicMock() sd.rssClient = MagicMock() sd.workingDirectory = '' sd.queueDict = {'aQueue': {'Site': 'LCG.CERN.cern', 'CEName': 'aCE', 'CEType': 'SSH', 'QueueName': 'aQueue', 'ParametersDict': {'CPUTime': 12345, 'Community': 'lhcb', 'OwnerGroup': ['lhcb_user'], 'Setup': 'LHCb-Production', 'Site': 'LCG.CERN.cern'}}} sd.queueSlots = {'aQueue': {'AvailableSlots': 10}} res = sd._submitPilotsToQueue(1, MagicMock(), 'aQueue') assert res['OK'] is True
def test__getPilotOptions(mocker): """ Testing SiteDirector()._getPilotOptions() """ mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule.__init__") mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.gConfig.getValue", side_effect=mockGCReply) mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.Operations", side_effect=mockOPS) mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.gProxyManager.requestToken", side_effect=mockPMReply) mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule", side_effect=mockAM) sd = SiteDirector() sd.log = gLogger sd.am_getOption = mockAM sd.log.setLevel('DEBUG') sd.queueDict = {'aQueue': {'CEName': 'aCE', 'QueueName': 'aQueue', 'ParametersDict': {'CPUTime': 12345, 'Community': 'lhcb', 'OwnerGroup': ['lhcb_user'], 'Setup': 'LHCb-Production', 'Site': 'LCG.CERN.cern', 'SubmitPool': ''}}} res = sd._getPilotOptions('aQueue', 10) assert res[0] == ['-S TestSetup', '-V 123', '-l 123', '-r 1,2,3', '-g 123', '-o /Security/ProxyToken=token', '-M 1', '-C T,e,s,t,S,e,t,u,p', '-e 1,2,3', '-N aCE', '-Q aQueue', '-n LCG.CERN.cern'] assert res[1] == 1
def test__submitPilotsToQueue(mocker): """ Testing SiteDirector()._submitPilotsToQueue() """ mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule.__init__") mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.gConfig.getValue", side_effect=mockGCReply) mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.CSGlobals.getSetup", side_effect=mockCSGlobalReply) mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.Resources.getCompatiblePlatforms", side_effect=mockResourcesReply) mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule", side_effect=mockAM) sd = SiteDirector() sd.log = gLogger sd.am_getOption = mockAM sd.log.setLevel('DEBUG') sd.rpcMatcher = MagicMock() sd.rssClient = MagicMock() sd.workingDirectory = '' sd.queueDict = {'aQueue': {'Site': 'LCG.CERN.cern', 'CEName': 'aCE', 'CEType': 'SSH', 'QueueName': 'aQueue', 'ParametersDict': {'CPUTime': 12345, 'Community': 'lhcb', 'OwnerGroup': ['lhcb_user'], 'Setup': 'LHCb-Production', 'Site': 'LCG.CERN.cern', 'SubmitPool': ''}}} sd.queueSlots = {'aQueue': {'AvailableSlots': 10}} res = sd._submitPilotsToQueue(1, MagicMock(), 'aQueue') assert res['OK'] is True assert res['Value'][0] == 0
def getQueues( self, resourceDict ): """ Get the list of relevant CEs and their descriptions """ result = SiteDirector.getQueues( self, resourceDict ) if not result['OK']: return result for queueName in self.queueDict.keys(): ce = self.queueDict[queueName]['CEName'] site = self.queueDict[queueName]['Site'] ceDef = resourceDict[site][ce] ceMaxProcessors = ceDef.get( 'MaxProcessors' ) maxProcessors = self.queueDict[queueName]['ParametersDict'].get( 'MaxProcessors', ceMaxProcessors ) if maxProcessors: maxProcessorsList = range( 1, int( maxProcessors ) + 1 ) processorsTags = ['%dProcessors' % processors for processors in maxProcessorsList] if processorsTags: self.queueDict[queueName]['ParametersDict'].setdefault( 'Tags', [] ) self.queueDict[queueName]['ParametersDict']['Tags'] += processorsTags ceWholeNode = ceDef.get( 'WholeNode', 'false' ) wholeNode = self.queueDict[queueName]['ParametersDict'].get( 'WholeNode', ceWholeNode ) if wholeNode.lower() in ( 'yes', 'true' ): self.queueDict[queueName]['ParametersDict'].setdefault( 'Tags', [] ) self.queueDict[queueName]['ParametersDict']['Tags'].append( 'WholeNode' ) if 'Tags' not in self.queueDict[queueName]['ParametersDict']: del self.queueDict[queueName] else: tags = self.queueDict[queueName]['ParametersDict']['Tags'] if '2Processors' not in tags and 'WholeNode' not in tags: del self.queueDict[queueName] return S_OK()
def test__ifAndWhereToSubmit(mocker, mockMatcherReturnValue, expected, anyExpected, sitesExpected): """ Testing SiteDirector()._ifAndWhereToSubmit() """ mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule.__init__") mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.gConfig.getValue", side_effect=mockGCReply) mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.CSGlobals.getSetup", side_effect=mockCSGlobalReply) mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule", side_effect=mockAM) sd = SiteDirector() sd.log = gLogger sd.am_getOption = mockAM sd.log.setLevel('DEBUG') sd.matcherClient = MagicMock() sd.matcherClient.getMatchingTaskQueues.return_value = mockMatcherReturnValue res = sd._ifAndWhereToSubmit() assert res[0] == expected if res[0]: assert res == (expected, anyExpected, sitesExpected, set())
def test__updatePilotStatus(mocker, pilotRefs, pilotDict, pilotCEDict, expected): """ Testing SiteDirector()._updatePilotStatus() """ mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule.__init__" ) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.gConfig.getValue", side_effect=mockGCReply) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.CSGlobals.getSetup", side_effect=mockCSGlobalReply) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule", side_effect=mockAM) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.pilotAgentsDB", side_effect=mockPilotAgentsDB) sd = SiteDirector() sd.log = gLogger sd.am_getOption = mockAM sd.log.setLevel('DEBUG') sd.rpcMatcher = MagicMock() sd.rssClient = MagicMock() res = sd._updatePilotStatus(pilotRefs, pilotDict, pilotCEDict) assert res == expected
def test__getPilotOptions(self, _patch1, _patch2, _patch3): sd = SiteDirector() sd.log = gLogger sd.am_getOption = mockAM sd.log.setLevel('DEBUG') sd.queueDict = {'aQueue': {'ParametersDict': {'CPUTime': 12345}}} sd.queueDict['aQueue'] = {} sd.queueDict['aQueue']['ParametersDict'] = {} res = sd._getPilotOptions('aQueue', 10) #FIXME: incomplete self.assertEqual(res, [None, None])
def _getPilotOptions( self, queue, pilotsToSubmit, **kwargs ): """ Prepare pilot options """ pilotOptions, pilotsToSubmit = OriginalSiteDirector._getPilotOptions(self, queue, pilotsToSubmit) # Get the module specific options if self.extraOptions: pilotOptions.append( self.extraOptions ) processors = kwargs.pop('processors', 1) if processors > 0: pilotOptions.append( '--maxNumberOfProcessors %u' % processors ) return [pilotOptions, pilotsToSubmit]
def setUp(self): self.mockAM = MagicMock() self.sd_m = importlib.import_module( 'DIRAC.WorkloadManagementSystem.Agent.SiteDirector') self.sd_m.AgentModule = self.mockAM self.sd = SiteDirector() self.sd.log = gLogger self.sd.am_getOption = self.mockAM self.sd.log.setLevel('DEBUG') self.tc_mock = MagicMock() self.tm_mock = MagicMock()
def test__ifAndWhereToSubmit(mocker, mockMatcherReturnValue, expected, anyExpected, sitesExpected): """ Testing SiteDirector()._ifAndWhereToSubmit() """ mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule.__init__" ) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.gConfig.getValue", side_effect=mockGCReply) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.CSGlobals.getSetup", side_effect=mockCSGlobalReply) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule", side_effect=mockAM) sd = SiteDirector() sd.log = gLogger sd.am_getOption = mockAM sd.log.setLevel('DEBUG') sd.matcherClient = MagicMock() sd.matcherClient.getMatchingTaskQueues.return_value = mockMatcherReturnValue res = sd._ifAndWhereToSubmit() assert res[0] == expected if res[0]: assert res == (expected, anyExpected, sitesExpected, set())
def test__getPilotOptions(self, _patch1, _patch2, _patch3, _patch4): """ Testing SiteDirector()._getPilotOptions() """ sd = SiteDirector() sd.log = gLogger sd.am_getOption = mockAM sd.log.setLevel('DEBUG') sd.queueDict = { 'aQueue': { 'CEName': 'aCE', 'QueueName': 'aQueue', 'ParametersDict': { 'CPUTime': 12345, 'Community': 'lhcb', 'OwnerGroup': ['lhcb_user'], 'Setup': 'LHCb-Production', 'Site': 'LCG.CERN.cern', 'SubmitPool': '' } } } res = sd._getPilotOptions('aQueue', 10) self.assertEqual(res[0], [ '-S TestSetup', '-V 123', '-l 123', '-r 1,2,3', '-g 123', '-o /Security/ProxyToken=token', '-M 1', '-C T,e,s,t,S,e,t,u,p', '-e 1,2,3', '-N aCE', '-Q aQueue', '-n LCG.CERN.cern' ]) self.assertEqual(res[1], 1)
def getQueues(self, resourceDict): """ Get the list of relevant CEs and their descriptions """ result = SiteDirector.getQueues(self, resourceDict) if not result['OK']: return result remQueues = [] for queueName in self.queueDict: ce = self.queueDict[queueName]['CEName'] site = self.queueDict[queueName]['Site'] ceDef = resourceDict[site][ce] ceMaxProcessors = ceDef.get('MaxProcessors') maxProcessors = self.queueDict[queueName]['ParametersDict'].get( 'MaxProcessors', ceMaxProcessors) if maxProcessors: maxProcessorsList = range(1, int(maxProcessors) + 1) processorsTags = [ '%dProcessors' % processors for processors in maxProcessorsList ] if processorsTags: self.queueDict[queueName]['ParametersDict'].setdefault( 'Tag', []) self.queueDict[queueName]['ParametersDict'][ 'Tag'] += processorsTags ceWholeNode = ceDef.get('WholeNode', 'false') wholeNode = self.queueDict[queueName]['ParametersDict'].get( 'WholeNode', ceWholeNode) if wholeNode.lower() in ('yes', 'true'): self.queueDict[queueName]['ParametersDict'].setdefault( 'Tag', []) self.queueDict[queueName]['ParametersDict']['Tag'].append( 'WholeNode') if 'Tag' not in self.queueDict[queueName]['ParametersDict']: remQueues.append(queueName) else: tags = self.queueDict[queueName]['ParametersDict']['Tag'] if '2Processors' not in tags and 'WholeNode' not in tags: remQueues.append(queueName) for queueName in remQueues: del self.queueDict[queueName] return S_OK()
def test__ifAndWhereToSubmit(self, _patch1, _patch2, _patch3, _patch4): """ Testing SiteDirector()._ifAndWhereToSubmit() """ sd = SiteDirector() sd.log = gLogger sd.am_getOption = mockAM sd.log.setLevel('DEBUG') sd.matcherClient = MagicMock() submit, _anySite, _jobSites, _testSites = sd._ifAndWhereToSubmit() self.assertTrue(submit)
def sd(mocker): """mocker for SiteDirector""" mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule.__init__" ) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.gConfig.getValue", side_effect=mockGCReply) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.Operations", side_effect=mockOPS) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.gProxyManager.requestToken", side_effect=mockPMReply) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule", side_effect=mockAM) sd = SiteDirector() sd.log = gLogger sd.am_getOption = mockAM sd.log.setLevel("DEBUG") sd.rpcMatcher = MagicMock() sd.rssClient = MagicMock() sd.workingDirectory = "" sd.queueDict = { "aQueue": { "Site": "LCG.CERN.cern", "CEName": "aCE", "CEType": "SSH", "QueueName": "aQueue", "ParametersDict": { "CPUTime": 12345, "Community": "lhcb", "OwnerGroup": ["lhcb_user"], "Setup": "LHCb-Production", "Site": "LCG.CERN.cern", }, } } return sd
def _getPilotOptions(self, queue, pilotsToSubmit): """ Adding LHCb specific options """ pilotOptions, newPilotsToSubmit = DIRACSiteDirector._getPilotOptions( self, queue, pilotsToSubmit) lhcbPilotCommands = [ 'LHCbGetPilotVersion', 'CheckWorkerNode', 'LHCbInstallDIRAC', 'LHCbConfigureBasics', 'CheckCECapabilities', 'CheckWNCapabilities', 'LHCbConfigureSite', 'LHCbConfigureArchitecture', 'LHCbConfigureCPURequirements', 'LaunchAgent' ] pilotOptions.append('-E LHCbPilot') pilotOptions.append('-X %s' % ','.join(lhcbPilotCommands)) if self.lbRunOnly: pilotOptions.append('-o lbRunOnly') return [pilotOptions, newPilotsToSubmit]
def test__updatePilotStatus(mocker, pilotRefs, pilotDict, pilotCEDict, expected): """ Testing SiteDirector()._updatePilotStatus() """ mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule.__init__") mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.gConfig.getValue", side_effect=mockGCReply) mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.CSGlobals.getSetup", side_effect=mockCSGlobalReply) mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule", side_effect=mockAM) mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.pilotAgentsDB", side_effect=mockPilotAgentsDB) sd = SiteDirector() sd.log = gLogger sd.am_getOption = mockAM sd.log.setLevel('DEBUG') sd.rpcMatcher = MagicMock() sd.rssClient = MagicMock() res = sd._updatePilotStatus(pilotRefs, pilotDict, pilotCEDict) assert res == expected
def beginExecution(self): """ just simple redefinition """ res = DIRACSiteDirector.beginExecution(self) if not res['OK']: return res if not self.pilot3: self.pilotFiles = [ os.path.join(rootPath, 'DIRAC', 'WorkloadManagementSystem', 'PilotAgent', 'dirac-pilot.py'), os.path.join(rootPath, 'DIRAC', 'WorkloadManagementSystem', 'PilotAgent', 'pilotCommands.py'), os.path.join(rootPath, 'DIRAC', 'WorkloadManagementSystem', 'PilotAgent', 'pilotTools.py'), os.path.join(rootPath, 'LHCbDIRAC', 'WorkloadManagementSystem', 'PilotAgent', 'LHCbPilotCommands.py') ] self.lbRunOnly = self.am_getOption('lbRunOnly', False) return S_OK()
def test__getPilotOptions(mocker): """ Testing SiteDirector()._getPilotOptions() """ mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule.__init__" ) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.gConfig.getValue", side_effect=mockGCReply) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.Operations", side_effect=mockOPS) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.gProxyManager.requestToken", side_effect=mockPMReply) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule", side_effect=mockAM) sd = SiteDirector() sd.log = gLogger sd.am_getOption = mockAM sd.log.setLevel('DEBUG') sd.queueDict = { 'aQueue': { 'CEName': 'aCE', 'QueueName': 'aQueue', 'ParametersDict': { 'CPUTime': 12345, 'Community': 'lhcb', 'OwnerGroup': ['lhcb_user'], 'Setup': 'LHCb-Production', 'Site': 'LCG.CERN.cern', 'SubmitPool': '' } } } res = sd._getPilotOptions('aQueue', 10) assert res[0] == [ '-S TestSetup', '-V 123', '-l 123', '-r 1,2,3', '-g 123', '-o /Security/ProxyToken=token', '-M 1', '-C T,e,s,t,S,e,t,u,p', '-e 1,2,3', '-N aCE', '-Q aQueue', '-n LCG.CERN.cern' ] assert res[1] == 1
def test__getPilotOptions(mocker): """ Testing SiteDirector()._getPilotOptions() """ mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule.__init__") mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.gConfig.getValue", side_effect=mockGCReply) mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.Operations", side_effect=mockOPS) mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.gProxyManager.requestToken", side_effect=mockPMReply) mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule", side_effect=mockAM) sd = SiteDirector() sd.log = gLogger sd.am_getOption = mockAM sd.log.setLevel('DEBUG') sd.queueDict = {'aQueue': {'CEName': 'aCE', 'QueueName': 'aQueue', 'ParametersDict': {'CPUTime': 12345, 'Community': 'lhcb', 'OwnerGroup': ['lhcb_user'], 'Setup': 'LHCb-Production', 'Site': 'LCG.CERN.cern'}}} res = sd._getPilotOptions('aQueue') assert set(['-S TestSetup', '-V 123', '-l 123', '-n LCG.CERN.cern']) <= set(res)
def beginExecution( self ): # Get the extra pilot options for this SiteDirector instance result = OriginalSiteDirector.beginExecution(self) self.extraModules = self.am_getOption( 'ExtraPilotModules', [] ) + DIRAC_MODULES self.extraOptions = self.am_getOption( "ExtraPilotOptions", '' ) return result
def test__allowedToSubmit(mocker): """ Testing SiteDirector()._allowedToSubmit() """ mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule.__init__" ) mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule", side_effect=mockAM) sd = SiteDirector() sd.log = gLogger sd.am_getOption = mockAM sd.log.setLevel('DEBUG') sd.queueDict = { 'aQueue': { 'Site': 'LCG.CERN.cern', 'CEName': 'aCE', 'QueueName': 'aQueue', 'ParametersDict': { 'CPUTime': 12345, 'Community': 'lhcb', 'OwnerGroup': ['lhcb_user'], 'Setup': 'LHCb-Production', 'Site': 'LCG.CERN.cern', 'SubmitPool': '' } } } submit = sd._allowedToSubmit('aQueue', True, set(['LCG.CERN.cern']), set()) assert submit is False sd.siteMaskList = ['LCG.CERN.cern', 'DIRAC.CNAF.it'] submit = sd._allowedToSubmit('aQueue', True, set(['LCG.CERN.cern']), set()) assert submit is True sd.rssFlag = True submit = sd._allowedToSubmit('aQueue', True, set(['LCG.CERN.cern']), set()) assert submit is False sd.ceMaskList = ['aCE', 'anotherCE'] submit = sd._allowedToSubmit('aQueue', True, set(['LCG.CERN.cern']), set()) assert submit is True
def test__allowedToSubmit(mocker): """ Testing SiteDirector()._allowedToSubmit() """ mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule.__init__") mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.AgentModule", side_effect=mockAM) sd = SiteDirector() sd.log = gLogger sd.am_getOption = mockAM sd.log.setLevel('DEBUG') sd.queueDict = {'aQueue': {'Site': 'LCG.CERN.cern', 'CEName': 'aCE', 'QueueName': 'aQueue', 'ParametersDict': {'CPUTime': 12345, 'Community': 'lhcb', 'OwnerGroup': ['lhcb_user'], 'Setup': 'LHCb-Production', 'Site': 'LCG.CERN.cern', 'SubmitPool': ''}}} submit = sd._allowedToSubmit('aQueue', True, set(['LCG.CERN.cern']), set()) assert submit is False sd.siteMaskList = ['LCG.CERN.cern', 'DIRAC.CNAF.it'] submit = sd._allowedToSubmit('aQueue', True, set(['LCG.CERN.cern']), set()) assert submit is True sd.rssFlag = True submit = sd._allowedToSubmit('aQueue', True, set(['LCG.CERN.cern']), set()) assert submit is False sd.ceMaskList = ['aCE', 'anotherCE'] submit = sd._allowedToSubmit('aQueue', True, set(['LCG.CERN.cern']), set()) assert submit is True
def test__allowedToSubmit(self, _patch1): """ Testing SiteDirector()._allowedToSubmit() """ sd = SiteDirector() sd.log = gLogger sd.am_getOption = mockAM sd.log.setLevel('DEBUG') sd.queueDict = { 'aQueue': { 'Site': 'LCG.CERN.cern', 'CEName': 'aCE', 'QueueName': 'aQueue', 'ParametersDict': { 'CPUTime': 12345, 'Community': 'lhcb', 'OwnerGroup': ['lhcb_user'], 'Setup': 'LHCb-Production', 'Site': 'LCG.CERN.cern', 'SubmitPool': '' } } } submit = sd._allowedToSubmit('aQueue', True, set(['LCG.CERN.cern']), set()) self.assertFalse(submit) sd.siteMaskList = ['LCG.CERN.cern', 'DIRAC.CNAF.it'] submit = sd._allowedToSubmit('aQueue', True, set(['LCG.CERN.cern']), set()) self.assertTrue(submit) sd.rssFlag = True submit = sd._allowedToSubmit('aQueue', True, set(['LCG.CERN.cern']), set()) self.assertFalse(submit) sd.ceMaskList = ['aCE', 'anotherCE'] submit = sd._allowedToSubmit('aQueue', True, set(['LCG.CERN.cern']), set()) self.assertTrue(submit)