def dli():
  theDLI = DownloadInputData({'InputData': [],
                              'Configuration': {'LocalSEList': ['SE_Local']},
                              'InputDataDirectory': 'CWD',
                              'FileCatalog': S_OK({'Successful': {'/a/lfn/1.txt': {'Size': 10,
                                                                                   'GUID': 'aGUID',
                                                                                   'SE_Local': '',
                                                                                   'SE_Remote': '',
                                                                                   'SE_Bad': '',
                                                                                   'SE_Tape': '',
                                                                                   }}})})
  theDLI.availableSEs = ['SE_Local', 'SE_Remote']
  return theDLI
def test_DLI_execute_NoLocal(dli, mockSE):
    """Data only at the remote SE."""
    dli = DownloadInputData({
        "InputData": [],
        "Configuration": {
            "LocalSEList": ["SE_Local", "SE_Tape"]
        },
        "InputDataDirectory":
        "CWD",
        "FileCatalog":
        S_OK({
            "Successful": {
                "/a/lfn/1.txt": {
                    "Size": 10,
                    "GUID": "aGUID",
                    "SE_Tape": "",
                }
            }
        }),
    })
    dli.availableSEs = ["SE_Local", "SE_Remote", "SE_Tape"]
    mockObjectSE = mockSE.return_value
    statDict = {"Read": True, "TapeSE": True, "DiskSE": False}
    mockObjectSE.getStatus.return_value = S_OK(statDict)
    mockObjectSE.status.return_value = statDict
    dli._downloadFromSE = MagicMock(return_value=S_ERROR("Failed to down"))
    dli._isCache = MagicMock(return_value=True)

    res = dli.execute(dataToResolve=["/a/lfn/1.txt"])
    assert res["OK"]
    assert res["Value"]["Failed"]
    assert "/a/lfn/1.txt" in res["Value"]["Failed"], res
    assert res["Value"]["Failed"][0] == "/a/lfn/1.txt", res
def test_DLI_execute_NoLocal(dli, mockSE):
    """Data only at the remote SE."""
    dli = DownloadInputData({
        'InputData': [],
        'Configuration': {
            'LocalSEList': ['SE_Local', 'SE_Tape']
        },
        'InputDataDirectory':
        'CWD',
        'FileCatalog':
        S_OK({
            'Successful': {
                '/a/lfn/1.txt': {
                    'Size': 10,
                    'GUID': 'aGUID',
                    'SE_Tape': '',
                }
            }
        })
    })
    dli.availableSEs = ['SE_Local', 'SE_Remote', 'SE_Tape']
    mockObjectSE = mockSE.return_value
    statDict = {'Read': True, 'TapeSE': True, 'DiskSE': False}
    mockObjectSE.getStatus.return_value = S_OK(statDict)
    mockObjectSE.status.return_value = statDict
    dli._downloadFromSE = MagicMock(return_value=S_ERROR('Failed to down'))
    dli._isCache = MagicMock(return_value=True)

    res = dli.execute(dataToResolve=['/a/lfn/1.txt'])
    assert res['OK']
    assert res['Value']['Failed']
    assert '/a/lfn/1.txt' in res['Value']['Failed'], res
    assert res['Value']['Failed'][0] == '/a/lfn/1.txt', res
Example #4
0
    def setUp(self):

        from DIRAC import gLogger
        gLogger.setLevel('DEBUG')

        self.mockDM = MagicMock()
        self.mockDM.return_value = dm_mock

        mockObjectSE = MagicMock()
        mockObjectSE.getFileMetadata.return_value = S_OK({
            'Successful': {
                '/a/lfn/1.txt': {
                    'Cached': 0
                },
                '/a/lfn/2.txt': {
                    'Cached': 1
                }
            },
            'Failed': {}
        })
        mockObjectSE.getFile.return_value = S_OK({
            'Successful': {
                '/a/lfn/1.txt': {}
            },
            'Failed': {}
        })
        mockObjectSE.getStatus.return_value = S_OK({
            'Read': True,
            'DiskSE': True
        })

        self.mockSE = MagicMock()
        self.mockSE.return_value = mockObjectSE

        self.dli = DownloadInputData({
            'InputData': [],
            'Configuration': 'boh',
            'FileCatalog': S_OK({'Successful': []})
        })

        self.pilotAgentsDBMock = MagicMock()
        self.jobDBMock = MagicMock()
        self.tqDBMock = MagicMock()
        self.jlDBMock = MagicMock()
        self.opsHelperMock = MagicMock()
        self.matcher = Matcher(pilotAgentsDB=self.pilotAgentsDBMock,
                               jobDB=self.jobDBMock,
                               tqDB=self.tqDBMock,
                               jlDB=self.jlDBMock,
                               opsHelper=self.opsHelperMock)
def dli():
    theDLI = DownloadInputData({
        "InputData": [],
        "Configuration": {
            "LocalSEList": ["SE_Local"]
        },
        "InputDataDirectory":
        "CWD",
        "FileCatalog":
        S_OK({
            "Successful": {
                "/a/lfn/1.txt": {
                    "Size": 10,
                    "GUID": "aGUID",
                    "SE_Local": "",
                    "SE_Remote": "",
                    "SE_Bad": "",
                    "SE_Tape": "",
                }
            }
        }),
    })
    theDLI.availableSEs = ["SE_Local", "SE_Remote"]
    return theDLI