Exemple #1
0
    def test_process_ok(self):

            glue2shareid = 'GLUE2ShareID=creamtest1_dteam_abc,GLUE2ServiceID=abc,GLUE2GroupID=resource,o=glue'
            ldif = """
dn: GLUE2PolicyID=creamtest1_dteam_abc_policy,%s
GLUE2PolicyUserDomainForeignKey: dteam
GLUE2MappingPolicyShareForeignKey: creamtest1_dteam_abc

dn: %s
GLUE2ShareID: creamtest1_dteam_abc
GLUE2ComputingShareMappingQueue: creamtest1
""" % (glue2shareid, glue2shareid)
            
            workspace = Workspace(vomap = self.vomap)
            workspace.setLRMSCmd(self._script())
            workspace.setGLUE2StaticFile(ldif)
            
            cfgfile = workspace.getConfigurationFile()
            config = DynSchedUtils.readConfigurationFromFile(cfgfile)
            
            dOut = DummyOutput()
            collector = Analyzer.analyze(config, {})
            GLUE2Handler.process(config, collector, dOut)
            
            result = dOut.queued[glue2shareid] == 1
            result = result and dOut.running[glue2shareid] == 2
            self.assertTrue(result)
Exemple #2
0
    def test_analyze_with_maxjobforvo(self):

            jTable = [
                      ("atlasprod", "creamtest1", 'running', 1327564866, "creXX_23081970"),
                      ("dteamgold", 'creamtest2', 'running', 1327566866, "creXX_23081972"),
                      ("dteamgold", "creamtest1", 'running', 1327567866, "creXX_23081973"),
                      ("infngridlow", 'creamtest1', 'running', 1327569866, "creXX_23081975"),
                      ("infngridlow", 'creamtest2', 'running', 1327570866, "creXX_23081976"),
                      ("infngridhigh", 'creamtest2', 'running', 1327572866, "creXX_23081978")
                     ]
            workspace = Workspace(vomap = self.vomap)
            
            script = self.headerfmt % (10, 4, 1327574866, 26)
            for jItem in jTable:
                script += self.dictfmt % jItem            
            script += self.footerfmt
            
            mJobTable = {'dteam': 5, 'atlas': 5, 'infngrid':5}
            
            workspace.setLRMSCmd(script)
            workspace.setMaxJobCmd(mJobTable)
            
            cfgfile = workspace.getConfigurationFile()
            config = DynSchedUtils.readConfigurationFromFile(cfgfile)
            
            collector = Analyzer.analyze(config, mJobTable)
            
            self.assertTrue(collector.freeSlots(None, 'dteam') == 3)
Exemple #3
0
    def test_process_missing_vo_in_policy(self):
        try:
            glue2shareid = 'GLUE2ShareID=creamtest1_dteam_abc,GLUE2ServiceID=abc,GLUE2GroupID=resource,o=glue'
            ldif = """
dn: %s
GLUE2ShareID: creamtest1_dteam_abc
GLUE2ComputingShareMappingQueue: creamtest1

dn: GLUE2PolicyID=creamtest1_dteam_abc_policy,%s
GLUE2MappingPolicyShareForeignKey: creamtest1_dteam_abc

""" % (glue2shareid, glue2shareid)

            workspace = Workspace(vomap = self.vomap)
            workspace.setLRMSCmd(self._script())
            workspace.setGLUE2StaticFile(ldif)
            
            cfgfile = workspace.getConfigurationFile()
            config = DynSchedUtils.readConfigurationFromFile(cfgfile)
            
            collector = Analyzer.analyze(config, {})
            GLUE2Handler.process(config, collector, DummyOutput())            
            self.fail("No exception detected")

        except GLUE2Handler.GLUE2Exception, glue_error:
            msg = str(glue_error)
            self.assertTrue(msg == "Missing mandatory attribute GLUE2PolicyUserDomainForeignKey")      
Exemple #4
0
    def test_process_ok(self):

            glueceuniqueid = 'GlueCEUniqueID=cream-38.pd.infn.it:8443/cream-pbs-creamtest1,mds-vo-name=resource,o=grid'
            gluevoviewid = 'GlueVOViewLocalID=dteam,' + glueceuniqueid
            ldif = """
dn: %s
GlueVOViewLocalID: dteam
GlueChunkKey: GlueCEUniqueID=cream-38.pd.infn.it:8443/cream-pbs-creamtest1
GlueCEAccessControlBaseRule: VO:dteam

dn: %s
GlueCEUniqueID: cream-38.pd.infn.it:8443/cream-pbs-creamtest1
GlueCEName: creamtest1
GlueCEAccessControlBaseRule: VO:infngrid
GlueCEAccessControlBaseRule: VO:dteam
""" % (gluevoviewid, glueceuniqueid)

            workspace = Workspace(vomap = self.vomap)            
            workspace.setLRMSCmd(self._script())
            workspace.setGLUE1StaticFile(ldif)
            
            cfgfile = workspace.getConfigurationFile()
            config = DynSchedUtils.readConfigurationFromFile(cfgfile)
            
            dOut = DummyOutput()
            collector = Analyzer.analyze(config, {})
            GLUE1Handler.process(config, collector, dOut)
            
            result = dOut.queued[glueceuniqueid] == 2
            result = result and dOut.running[glueceuniqueid] == 4
            result = result and dOut.queued[gluevoviewid] == 1
            result = result and dOut.running[gluevoviewid] == 2
            self.assertTrue(result)
Exemple #5
0
    def test_process_missingce(self):
        try:
            glueceuniqueid = 'GlueCEUniqueID=cream-38.pd.infn.it:8443/cream-pbs-creamtest1,mds-vo-name=resource,o=grid'
            gluevoviewid = 'GlueVOViewLocalID=dteam,' + glueceuniqueid
            ldif = """
dn: %s
GlueVOViewLocalID: dteam
GlueChunkKey: GlueCEUniqueID=cream-38.pd.infn.it:8443/cream-pbs-creamtest1
GlueCEAccessControlBaseRule: VO:dteam
""" % gluevoviewid
            
            workspace = Workspace(vomap = self.vomap)
            workspace.setLRMSCmd(self._script())
            workspace.setGLUE1StaticFile(ldif)
            
            cfgfile = workspace.getConfigurationFile()
            config = DynSchedUtils.readConfigurationFromFile(cfgfile)
            
            dOut = DummyOutput()
            collector = Analyzer.analyze(config, {})
            GLUE1Handler.process(config, collector, dOut)            
            self.fail("No exception detected")
        
        except GLUE1Handler.GLUE1Exception, glue_error:
            msg = str(glue_error)
            self.assertTrue(msg.startswith("Invalid foreign key"))      
Exemple #6
0
    def test_analyze_err_from_script(self):
        try:
            workspace = Workspace(vomap = self.vomap)
            script = """#!/usr/bin/python
import sys
sys.stderr.write("Dummy error message")
sys.exit(1)
"""
            workspace.setLRMSCmd(script)
            
            cfgfile = workspace.getConfigurationFile()
            config = DynSchedUtils.readConfigurationFromFile(cfgfile)
            
            collector = Analyzer.analyze(config, {})
        
            self.fail("Exception not handled")
            
        except Analyzer.AnalyzeException, test_error:
            msg = str(test_error)
            self.assertTrue(msg.startswith("Dummy error message"))
Exemple #7
0
    def test_process_missing_share(self):
        try:
            ldif = """
dn: GLUE2PolicyID=creamtest1_dteam_abc_policy,GLUE2ShareID=creamtest1_dteam_abc,GLUE2ServiceID=abc,GLUE2GroupID=resource,o=glue
GLUE2PolicyUserDomainForeignKey: dteam
GLUE2MappingPolicyShareForeignKey: creamtest1_dteam_abc

"""
            workspace = Workspace(vomap = self.vomap)
            workspace.setLRMSCmd(self._script())
            workspace.setGLUE2StaticFile(ldif)
            
            cfgfile = workspace.getConfigurationFile()
            config = DynSchedUtils.readConfigurationFromFile(cfgfile)
            
            collector = Analyzer.analyze(config, {})
            GLUE2Handler.process(config, collector, DummyOutput())            
            self.fail("No exception detected")

        except GLUE2Handler.GLUE2Exception, glue_error:
            msg = str(glue_error)
            self.assertTrue(msg.startswith("Invalid foreign key"))      
Exemple #8
0
 def test_analyze_ok(self):
     
         jTable = [
                   ("atlasprod", "creamtest1", 'running', 1327564866, "creXX_23081970"),
                   ("atlasprod", 'creamtest2', 'queued', 1327565866, "creXX_23081971"),
                   ("dteamgold", 'creamtest2', 'running', 1327566866, "creXX_23081972"),
                   ("dteamgold", "creamtest1", 'running', 1327567866, "creXX_23081973"),
                   ("dteamgold", 'creamtest2', 'queued', 1327568866, "creXX_23081974"),
                   ("infngridlow", 'creamtest1', 'running', 1327569866, "creXX_23081975"),
                   ("infngridlow", 'creamtest2', 'running', 1327570866, "creXX_23081976"),
                   ("infngridhigh", 'creamtest1', 'running', 1327571866, "creXX_23081977"),
                   ("infngridhigh", 'creamtest2', 'running', 1327572866, "creXX_23081978"),
                   ("infngridhigh", 'creamtest1', 'queued', 1327573866, "creXX_23081979")
                  ]
         workspace = Workspace(vomap = self.vomap)
         
         script = self.headerfmt % (5, 0, 1327574866, 26)
         for jItem in jTable:
             script += self.dictfmt % jItem            
         script += self.footerfmt
         
         workspace.setLRMSCmd(script)
         
         cfgfile = workspace.getConfigurationFile()
         config = DynSchedUtils.readConfigurationFromFile(cfgfile)
         
         collector = Analyzer.analyze(config, {})
         
         result =            collector.runningJobsForVO('atlas') == 1
         result = result and collector.queuedJobsForVO('atlas') == 1
         result = result and collector.runningJobsForVO('dteam') == 2
         result = result and collector.queuedJobsForVO('dteam') == 1
         result = result and collector.runningJobsForVO('infngrid') == 4
         result = result and collector.queuedJobsForVO('infngrid') == 1
         
         self.assertTrue(result)