def test__ByJobType(self):

        ourPG = importlib.import_module(
            'DIRAC.TransformationSystem.Client.TaskManagerPlugin')
        ourPG.getSites = getSitesFake
        ourPG.getSitesForSE = getSitesForSE

        # "User" case - 1
        p_o = TaskManagerPlugin('ByJobType',
                                operationsHelper=opsHelperFakeUser())

        p_o.params = {'Site': '', 'TargetSE': 'CERN-DST', 'JobType': 'User'}
        res = p_o.run()
        self.assertEqual(res, set(['CERN', 'CSCS', 'IN2P3']))

        p_o.params = {'Site': '', 'TargetSE': 'IN2P3-DST', 'JobType': 'User'}
        res = p_o.run()
        self.assertEqual(res, set(['IN2P3', 'Paris', 'CSCS', 'CERN']))

        p_o.params = {
            'Site': '',
            'TargetSE': ['CERN-DST', 'CSCS-DST'],
            'JobType': 'User'
        }
        res = p_o.run()
        self.assertEqual(res, set(['CERN', 'CSCS', 'IN2P3']))

        # "User" case - 2
        p_o = TaskManagerPlugin('ByJobType',
                                operationsHelper=opsHelperFakeUser2())

        p_o.params = {'Site': '', 'TargetSE': 'CERN-DST', 'JobType': 'User'}
        res = p_o.run()
        self.assertEqual(res, set(['CERN', 'CSCS']))

        p_o.params = {'Site': '', 'TargetSE': 'IN2P3-DST', 'JobType': 'User'}
        res = p_o.run()
        self.assertEqual(res, set(['IN2P3', 'Paris', 'CSCS']))

        p_o.params = {
            'Site': '',
            'TargetSE': ['CERN-DST', 'CSCS-DST'],
            'JobType': 'User'
        }
        res = p_o.run()
        self.assertEqual(res, set(['CERN', 'CSCS']))

        # "DataReconstruction" case
        p_o = TaskManagerPlugin('ByJobType',
                                operationsHelper=opsHelperFakeDataReco())

        p_o.params = {
            'Site': '',
            'TargetSE': 'CERN-DST',
            'JobType': 'DataReconstruction'
        }
        res = p_o.run()
        self.assertEqual(
            res, set(['Bologna', 'Ferrara', 'Paris', 'CSCS', 'IN2P3', 'CERN']))

        p_o.params = {
            'Site': '',
            'TargetSE': 'IN2P3-DST',
            'JobType': 'DataReconstruction'
        }
        res = p_o.run()
        self.assertEqual(res, set(['Bologna', 'Paris', 'CSCS', 'IN2P3']))

        # "Hospital" case: all sites go to hospital only
        p_o = TaskManagerPlugin('ByJobType',
                                operationsHelper=opsHelperFakeHospital())

        p_o.params = {
            'Site': '',
            'TargetSE': 'CERN-DST',
            'JobType': 'DataReconstruction'
        }
        res = p_o.run()
        self.assertEqual(res, set(['Hospital']))

        p_o.params = {
            'Site': '',
            'TargetSE': 'IN2P3-DST',
            'JobType': 'DataReconstruction'
        }
        res = p_o.run()
        self.assertEqual(res, set(['Hospital']))

        # "Merge" case - 1
        p_o = TaskManagerPlugin('ByJobType',
                                operationsHelper=opsHelperFakeMerge())

        p_o.params = {'Site': '', 'TargetSE': 'CERN-DST', 'JobType': 'Merge'}
        res = p_o.run()
        self.assertEqual(res, set(['CERN']))

        p_o.params = {'Site': '', 'TargetSE': 'IN2P3-DST', 'JobType': 'Merge'}
        res = p_o.run()
        self.assertEqual(res, set(['IN2P3']))

        # "Merge" case - 2
        p_o = TaskManagerPlugin('ByJobType',
                                operationsHelper=opsHelperFakeMerge2())

        p_o.params = {'Site': '', 'TargetSE': 'CERN-DST', 'JobType': 'Merge'}
        res = p_o.run()
        self.assertEqual(res, set(['CERN']))

        p_o.params = {'Site': '', 'TargetSE': 'IN2P3-DST', 'JobType': 'Merge'}
        res = p_o.run()
        self.assertEqual(res, set(['IN2P3']))

        # "MC" case
        p_o = TaskManagerPlugin('ByJobType',
                                operationsHelper=opsHelperFakeMC())

        p_o.params = {'Site': '', 'TargetSE': '', 'JobType': 'MC'}
        res = p_o.run()
        self.assertEqual(
            res,
            set([
                'CERN', 'IN2P3', 'Bologna', 'Ferrara', 'Paris', 'CSCS', 'PAK',
                'Hospital'
            ]))

        p_o.params = {'Site': '', 'TargetSE': '', 'JobType': 'MC'}
        res = p_o.run()
        self.assertEqual(
            res,
            set([
                'CERN', 'IN2P3', 'Bologna', 'Ferrara', 'Paris', 'CSCS', 'PAK',
                'Hospital'
            ]))
    def test__BySE(self):

        ourPG = importlib.import_module(
            'DIRAC.TransformationSystem.Client.TaskManagerPlugin')
        ourPG.getSitesForSE = getSitesForSE
        p_o = TaskManagerPlugin('BySE', operationsHelper=MagicMock())

        p_o.params = {'Site': '', 'TargetSE': ''}
        res = p_o.run()
        self.assertEqual(res, set([]))

        p_o.params = {'Site': 'ANY', 'TargetSE': ''}
        res = p_o.run()
        self.assertEqual(res, set([]))

        p_o.params = {'TargetSE': 'Unknown'}
        res = p_o.run()
        self.assertEqual(res, set([]))

        p_o.params = {'Site': 'Site1;Site2', 'TargetSE': ''}
        res = p_o.run()
        self.assertEqual(res, set([]))

        p_o.params = {'TargetSE': 'CERN-DST'}
        res = p_o.run()
        self.assertEqual(res, set(['CERN']))

        p_o.params = {'TargetSE': 'IN2P3-DST'}
        res = p_o.run()
        self.assertEqual(res, set(['IN2P3']))

        p_o.params = {'TargetSE': 'CERN-DST,CSCS-DST'}
        res = p_o.run()
        self.assertEqual(res, set(['CERN', 'CSCS']))

        p_o.params = {'TargetSE': ['CERN-DST', 'CSCS-DST']}
        res = p_o.run()
        self.assertEqual(res, set(['CERN', 'CSCS']))
  def test__ByJobType(self):

    ourPG = importlib.import_module('DIRAC.TransformationSystem.Client.TaskManagerPlugin')
    ourPG.getSites = getSitesFake
    ourPG.getSitesForSE = getSitesForSE

    # "User" case - 1
    p_o = TaskManagerPlugin('ByJobType', operationsHelper=opsHelperFakeUser())

    p_o.params = {'Site': '', 'TargetSE': 'CERN-DST', 'JobType': 'User'}
    res = p_o.run()
    self.assertEqual(res, set(['CERN', 'CSCS', 'IN2P3']))

    p_o.params = {'Site': '', 'TargetSE': 'IN2P3-DST', 'JobType': 'User'}
    res = p_o.run()
    self.assertEqual(res, set(['IN2P3', 'Paris', 'CSCS', 'CERN']))

    p_o.params = {'Site': '', 'TargetSE': ['CERN-DST', 'CSCS-DST'], 'JobType': 'User'}
    res = p_o.run()
    self.assertEqual(res, set(['CERN', 'CSCS', 'IN2P3']))

    # "User" case - 2
    p_o = TaskManagerPlugin('ByJobType', operationsHelper=opsHelperFakeUser2())

    p_o.params = {'Site': '', 'TargetSE': 'CERN-DST', 'JobType': 'User'}
    res = p_o.run()
    self.assertEqual(res, set(['CERN', 'CSCS']))

    p_o.params = {'Site': '', 'TargetSE': 'IN2P3-DST', 'JobType': 'User'}
    res = p_o.run()
    self.assertEqual(res, set(['IN2P3', 'Paris', 'CSCS']))

    p_o.params = {'Site': '', 'TargetSE': ['CERN-DST', 'CSCS-DST'], 'JobType': 'User'}
    res = p_o.run()
    self.assertEqual(res, set(['CERN', 'CSCS']))

    # "DataReconstruction" case
    p_o = TaskManagerPlugin('ByJobType', operationsHelper=opsHelperFakeDataReco())

    p_o.params = {'Site': '', 'TargetSE': 'CERN-DST', 'JobType': 'DataReconstruction'}
    res = p_o.run()
    self.assertEqual(res, set(['Bologna', 'Ferrara', 'Paris', 'CSCS', 'IN2P3', 'CERN']))

    p_o.params = {'Site': '', 'TargetSE': 'IN2P3-DST', 'JobType': 'DataReconstruction'}
    res = p_o.run()
    self.assertEqual(res, set(['Bologna', 'Paris', 'CSCS', 'IN2P3']))

    # "Hospital" case: all sites go to hospital only
    p_o = TaskManagerPlugin('ByJobType', operationsHelper=opsHelperFakeHospital())

    p_o.params = {'Site': '', 'TargetSE': 'CERN-DST', 'JobType': 'DataReconstruction'}
    res = p_o.run()
    self.assertEqual(res, set(['Hospital']))

    p_o.params = {'Site': '', 'TargetSE': 'IN2P3-DST', 'JobType': 'DataReconstruction'}
    res = p_o.run()
    self.assertEqual(res, set(['Hospital']))

    # "Merge" case - 1
    p_o = TaskManagerPlugin('ByJobType', operationsHelper=opsHelperFakeMerge())

    p_o.params = {'Site': '', 'TargetSE': 'CERN-DST', 'JobType': 'Merge'}
    res = p_o.run()
    self.assertEqual(res, set(['CERN']))

    p_o.params = {'Site': '', 'TargetSE': 'IN2P3-DST', 'JobType': 'Merge'}
    res = p_o.run()
    self.assertEqual(res, set(['IN2P3']))

    # "Merge" case - 2
    p_o = TaskManagerPlugin('ByJobType', operationsHelper=opsHelperFakeMerge2())

    p_o.params = {'Site': '', 'TargetSE': 'CERN-DST', 'JobType': 'Merge'}
    res = p_o.run()
    self.assertEqual(res, set(['CERN']))

    p_o.params = {'Site': '', 'TargetSE': 'IN2P3-DST', 'JobType': 'Merge'}
    res = p_o.run()
    self.assertEqual(res, set(['IN2P3']))

    # "MC" case
    p_o = TaskManagerPlugin('ByJobType', operationsHelper=opsHelperFakeMC())

    p_o.params = {'Site': '', 'TargetSE': '', 'JobType': 'MC'}
    res = p_o.run()
    self.assertEqual(res, set(['CERN', 'IN2P3', 'Bologna', 'Ferrara', 'Paris', 'CSCS', 'PAK', 'Hospital']))

    p_o.params = {'Site': '', 'TargetSE': '', 'JobType': 'MC'}
    res = p_o.run()
    self.assertEqual(res, set(['CERN', 'IN2P3', 'Bologna', 'Ferrara', 'Paris', 'CSCS', 'PAK', 'Hospital']))
  def test__BySE(self):

    ourPG = importlib.import_module('DIRAC.TransformationSystem.Client.TaskManagerPlugin')
    ourPG.getSitesForSE = getSitesForSE
    p_o = TaskManagerPlugin('BySE', operationsHelper=MagicMock())

    p_o.params = {'Site': '', 'TargetSE': ''}
    res = p_o.run()
    self.assertEqual(res, set([]))

    p_o.params = {'Site': 'ANY', 'TargetSE': ''}
    res = p_o.run()
    self.assertEqual(res, set([]))

    p_o.params = {'TargetSE': 'Unknown'}
    res = p_o.run()
    self.assertEqual(res, set([]))

    p_o.params = {'Site': 'Site1;Site2', 'TargetSE': ''}
    res = p_o.run()
    self.assertEqual(res, set([]))

    p_o.params = {'TargetSE': 'CERN-DST'}
    res = p_o.run()
    self.assertEqual(res, set(['CERN']))

    p_o.params = {'TargetSE': 'IN2P3-DST'}
    res = p_o.run()
    self.assertEqual(res, set(['IN2P3']))

    p_o.params = {'TargetSE': 'CERN-DST,CSCS-DST'}
    res = p_o.run()
    self.assertEqual(res, set(['CERN', 'CSCS']))

    p_o.params = {'TargetSE': ['CERN-DST', 'CSCS-DST']}
    res = p_o.run()
    self.assertEqual(res, set(['CERN', 'CSCS']))
Exemplo n.º 5
0
    def test__ByJobType(self):

        ourPG = importlib.import_module(
            "DIRAC.TransformationSystem.Client.TaskManagerPlugin")
        ourPG.getSites = getSitesFake
        ourPG.getSitesForSE = getSitesForSE

        # "User" case - 1
        p_o = TaskManagerPlugin("ByJobType",
                                operationsHelper=opsHelperFakeUser())

        p_o.params = {"Site": "", "TargetSE": "CERN-DST", "JobType": "User"}
        res = p_o.run()
        self.assertEqual(res, set(["CERN", "CSCS", "IN2P3"]))

        p_o.params = {"Site": "", "TargetSE": "IN2P3-DST", "JobType": "User"}
        res = p_o.run()
        self.assertEqual(res, set(["IN2P3", "Paris", "CSCS", "CERN"]))

        p_o.params = {
            "Site": "",
            "TargetSE": ["CERN-DST", "CSCS-DST"],
            "JobType": "User"
        }
        res = p_o.run()
        self.assertEqual(res, set(["CERN", "CSCS", "IN2P3"]))

        # "User" case - 2
        p_o = TaskManagerPlugin("ByJobType",
                                operationsHelper=opsHelperFakeUser2())

        p_o.params = {"Site": "", "TargetSE": "CERN-DST", "JobType": "User"}
        res = p_o.run()
        self.assertEqual(res, set(["CERN", "CSCS"]))

        p_o.params = {"Site": "", "TargetSE": "IN2P3-DST", "JobType": "User"}
        res = p_o.run()
        self.assertEqual(res, set(["IN2P3", "Paris", "CSCS"]))

        p_o.params = {
            "Site": "",
            "TargetSE": ["CERN-DST", "CSCS-DST"],
            "JobType": "User"
        }
        res = p_o.run()
        self.assertEqual(res, set(["CERN", "CSCS"]))

        # "DataReconstruction" case
        p_o = TaskManagerPlugin("ByJobType",
                                operationsHelper=opsHelperFakeDataReco())

        p_o.params = {
            "Site": "",
            "TargetSE": "CERN-DST",
            "JobType": "DataReconstruction"
        }
        res = p_o.run()
        self.assertEqual(
            res, set(["Bologna", "Ferrara", "Paris", "CSCS", "IN2P3", "CERN"]))

        p_o.params = {
            "Site": "",
            "TargetSE": "IN2P3-DST",
            "JobType": "DataReconstruction"
        }
        res = p_o.run()
        self.assertEqual(res, set(["Bologna", "Paris", "CSCS", "IN2P3"]))

        # "Hospital" case: all sites go to hospital only
        p_o = TaskManagerPlugin("ByJobType",
                                operationsHelper=opsHelperFakeHospital())

        p_o.params = {
            "Site": "",
            "TargetSE": "CERN-DST",
            "JobType": "DataReconstruction"
        }
        res = p_o.run()
        self.assertEqual(res, set(["Hospital"]))

        p_o.params = {
            "Site": "",
            "TargetSE": "IN2P3-DST",
            "JobType": "DataReconstruction"
        }
        res = p_o.run()
        self.assertEqual(res, set(["Hospital"]))

        # "Merge" case - 1
        p_o = TaskManagerPlugin("ByJobType",
                                operationsHelper=opsHelperFakeMerge())

        p_o.params = {"Site": "", "TargetSE": "CERN-DST", "JobType": "Merge"}
        res = p_o.run()
        self.assertEqual(res, set(["CERN"]))

        p_o.params = {"Site": "", "TargetSE": "IN2P3-DST", "JobType": "Merge"}
        res = p_o.run()
        self.assertEqual(res, set(["IN2P3"]))

        # "Merge" case - 2
        p_o = TaskManagerPlugin("ByJobType",
                                operationsHelper=opsHelperFakeMerge2())

        p_o.params = {"Site": "", "TargetSE": "CERN-DST", "JobType": "Merge"}
        res = p_o.run()
        self.assertEqual(res, set(["CERN"]))

        p_o.params = {"Site": "", "TargetSE": "IN2P3-DST", "JobType": "Merge"}
        res = p_o.run()
        self.assertEqual(res, set(["IN2P3"]))

        # "MC" case
        p_o = TaskManagerPlugin("ByJobType",
                                operationsHelper=opsHelperFakeMC())

        p_o.params = {"Site": "", "TargetSE": "", "JobType": "MC"}
        res = p_o.run()
        self.assertEqual(
            res,
            set([
                "CERN", "IN2P3", "Bologna", "Ferrara", "Paris", "CSCS", "PAK",
                "Hospital"
            ]))

        p_o.params = {"Site": "", "TargetSE": "", "JobType": "MC"}
        res = p_o.run()
        self.assertEqual(
            res,
            set([
                "CERN", "IN2P3", "Bologna", "Ferrara", "Paris", "CSCS", "PAK",
                "Hospital"
            ]))
Exemplo n.º 6
0
    def test__BySE(self):

        ourPG = importlib.import_module(
            "DIRAC.TransformationSystem.Client.TaskManagerPlugin")
        ourPG.getSitesForSE = getSitesForSE
        p_o = TaskManagerPlugin("BySE", operationsHelper=MagicMock())

        p_o.params = {"Site": "", "TargetSE": ""}
        res = p_o.run()
        self.assertEqual(res, set([]))

        p_o.params = {"Site": "ANY", "TargetSE": ""}
        res = p_o.run()
        self.assertEqual(res, set([]))

        p_o.params = {"TargetSE": "Unknown"}
        res = p_o.run()
        self.assertEqual(res, set([]))

        p_o.params = {"Site": "Site1;Site2", "TargetSE": ""}
        res = p_o.run()
        self.assertEqual(res, set([]))

        p_o.params = {"TargetSE": "CERN-DST"}
        res = p_o.run()
        self.assertEqual(res, set(["CERN"]))

        p_o.params = {"TargetSE": "IN2P3-DST"}
        res = p_o.run()
        self.assertEqual(res, set(["IN2P3"]))

        p_o.params = {"TargetSE": "CERN-DST,CSCS-DST"}
        res = p_o.run()
        self.assertEqual(res, set(["CERN", "CSCS"]))

        p_o.params = {"TargetSE": ["CERN-DST", "CSCS-DST"]}
        res = p_o.run()
        self.assertEqual(res, set(["CERN", "CSCS"]))