Skip to content

Commit

Permalink
removing SE Obj caching
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza Zafar authored and andresailer committed Dec 1, 2017
1 parent 2ed69a6 commit 60e16a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
10 changes: 1 addition & 9 deletions ILCTransformationSystem/Agent/FileStatusTransformationAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def __init__(self, *args, **kwargs):
self.addressFrom = "ilcdirac-admin@cern.ch"
self.emailSubject = "FileStatusTransformationAgent"

self.seObjDict = {}
self.accounting = {}

self.fcClient = FileCatalogClient()
Expand Down Expand Up @@ -434,16 +433,9 @@ def existsOnSE(self, storageElements, lfns):

voName = lfns[0].split('/')[1]
for se in storageElements:
if voName not in self.seObjDict:
self.seObjDict[voName] = {}
if se not in self.seObjDict[voName]:
self.seObjDict[voName][se] = StorageElement(se, vo=voName)
seObj = self.seObjDict[voName][se]

res = seObj.exists(lfns)
res = StorageElement(se, vo=voName).exists(lfns)
if not res['OK']:
return res

for lfn, status in res['Value']['Successful'].items():
if lfn not in result['Successful']:
result['Successful'][lfn] = status
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
""" Test FileStatusTransformationAgent """

import unittest
import importlib

import ILCDIRAC.ILCTransformationSystem.Agent.FileStatusTransformationAgent as FST
import DIRAC.Resources.Storage.StorageElement as SeModule
from ILCDIRAC.ILCTransformationSystem.Agent.FileStatusTransformationAgent import FileStatusTransformationAgent

from mock import MagicMock
Expand Down Expand Up @@ -186,20 +186,13 @@ def test_exists_on_storage_element(self):

files = [fileExists, fileOneRepLost, fileAllRepLost, fileFailed]

self.fstAgent.seObjDict['ilc'] = {}
self.fstAgent.seObjDict['ilc'][se1] = MagicMock()
self.fstAgent.seObjDict['ilc'][se2] = MagicMock()
se1Result = S_OK({'Successful': {fileExists: True, fileOneRepLost: True, fileAllRepLost: False, fileFailed: True},
'Failed': {}})

self.fstAgent.seObjDict['ilc'][se1].exists.return_value = S_OK({'Successful': {fileExists: True,
fileOneRepLost: True,
fileAllRepLost: False,
fileFailed: True},
'Failed': {}})
self.fstAgent.seObjDict['ilc'][se2].exists.return_value = S_OK({'Successful': {fileExists: True,
fileOneRepLost: False,
fileAllRepLost: False},
'Failed': {fileFailed: 'permission denied'}})
se2Result = S_OK({'Successful': {fileExists: True, fileOneRepLost: False, fileAllRepLost: False},
'Failed': {fileFailed: 'permission denied'}})

SeModule.StorageElementItem.exists = MagicMock(side_effect=[se1Result, se2Result])
res = self.fstAgent.existsOnSE(storageElements, files)['Value']

self.assertTrue(res['Successful'][fileExists])
Expand Down

0 comments on commit 60e16a2

Please sign in to comment.