Ejemplo n.º 1
0
class MoveReplicaSuccess( ReqOpsTestCase ):

  def setUp(self):
    self.op = Operation()
    self.op.Type = "MoveFile"
    self.op.SourceSE = "%s,%s" % ( "sourceSE1", "sourceSE2" )
    self.op.TargetSE = "%s,%s" % ( "targetSE1", "targetSE2" )

    self.File = File()
    self.File.LFN = '/cta/file1'
    self.File.Size = 2L
    self.File.Checksum = '011300a2'
    self.File.ChecksumType = "adler32"
    self.op.addFile( self.File )

    self.req = Request()
    self.req.addOperation( self.op )
    self.mr = MoveReplica( self.op )

    self.mr.dm = MagicMock()
    self.mr.fc = MagicMock()

  # This test needs to be fixed. It currently fails because StorageElement is not mocked
  '''def test__dmTransfer( self ):

    successful = {}
    for sourceSE in self.op.sourceSEList:
      successful[sourceSE] = 'dips://' + sourceSE.lower() + ':9148/DataManagement/StorageElement' + self.File.LFN

    res = {'OK': True, 'Value': {'Successful': {self.File.LFN : successful}, 'Failed': {}}}
    self.mr.dm.getActiveReplicas.return_value = res

    res = {'OK': True, 'Value': {'Successful': {self.File.LFN : {'register': 0.1228799819946289, 'replicate': 9.872732877731323}}, 'Failed': {}}}
    self.mr.dm.replicateAndRegister.return_value = res

    res = self.mr.dmTransfer( self.File )
    self.assertTrue( res['OK'] )

    self.assertEqual( self.mr.operation.__files__[0].Status, 'Waiting' )
    self.assertEqual( self.mr.operation.Status, 'Waiting' )
    self.assertEqual( self.mr.request.Status, 'Waiting' )'''

  def test__dmRemoval( self ):

    res = {'OK': True, 'Value': {'Successful': { self.File.LFN : {'DIRACFileCatalog': True}}, 'Failed': {}}}
    self.mr.dm.removeReplica.return_value = res

    toRemoveDict = {self.File.LFN: self.File}
    targetSEs = self.op.sourceSEList

    res = self.mr.dmRemoval( toRemoveDict, targetSEs )
    self.assertTrue( res['OK'] )

    resvalue = dict( [ ( targetSE, '' ) for targetSE in targetSEs ] )
    self.assertEqual( res['Value'], {self.File.LFN: resvalue} )

    self.assertEqual( self.mr.operation.__files__[0].Status, 'Done' )
    self.assertEqual( self.mr.operation.Status, 'Done' )
    self.assertEqual( self.mr.request.Status, 'Done' )
Ejemplo n.º 2
0
class MoveReplicaSuccess( ReqOpsTestCase ):

    def setUp(self):
      self.op = Operation()
      self.op.Type = "MoveFile"
      self.op.SourceSE = "%s,%s" % ( "sourceSE1", "sourceSE2" )
      self.op.TargetSE = "%s,%s" % ( "targetSE1", "targetSE2" )

      self.File = File()
      self.File.LFN = '/cta/file1'
      self.File.Size = 2L
      self.File.Checksum = '011300a2'
      self.File.ChecksumType = "adler32"
      self.op.addFile( self.File )

      self.req = Request()
      self.req.addOperation( self.op )
      self.mr = MoveReplica( self.op )

      self.mr.dm = MagicMock()
      self.mr.fc = MagicMock()

    # This test needs to be fixed. It currently fails because StorageElement is not mocked
    '''def test__dmTransfer( self ):

      successful = {}
      for sourceSE in self.op.sourceSEList:
        successful[sourceSE] = 'dips://' + sourceSE.lower() + ':9148/DataManagement/StorageElement' + self.File.LFN

      res = {'OK': True, 'Value': {'Successful': {self.File.LFN : successful}, 'Failed': {}}}
      self.mr.dm.getActiveReplicas.return_value = res

      res = {'OK': True, 'Value': {'Successful': {self.File.LFN : {'register': 0.1228799819946289, 'replicate': 9.872732877731323}}, 'Failed': {}}}
      self.mr.dm.replicateAndRegister.return_value = res

      res = self.mr.dmTransfer( self.File )
      self.assertTrue( res['OK'] )

      self.assertEqual( self.mr.operation.__files__[0].Status, 'Waiting' )
      self.assertEqual( self.mr.operation.Status, 'Waiting' )
      self.assertEqual( self.mr.request.Status, 'Waiting' )'''

    def test__dmRemoval( self ):

      res = {'OK': True, 'Value': {'Successful': { self.File.LFN : {'DIRACFileCatalog': True}}, 'Failed': {}}}
      self.mr.dm.removeReplica.return_value = res

      toRemoveDict = {self.File.LFN: self.File}
      targetSEs = self.op.sourceSEList

      res = self.mr.dmRemoval( toRemoveDict, targetSEs )
      self.assertTrue( res['OK'] )

      resvalue = dict( [ ( targetSE, '' ) for targetSE in targetSEs ] )
      self.assertEqual( res['Value'], {self.File.LFN: resvalue} )

      self.assertEqual( self.mr.operation.__files__[0].Status, 'Done' )
      self.assertEqual( self.mr.operation.Status, 'Done' )
      self.assertEqual( self.mr.request.Status, 'Done' )
Ejemplo n.º 3
0
  def setUp(self):
    self.op = Operation()
    self.op.Type = "MoveFile"
    self.op.SourceSE = "%s,%s" % ( "sourceSE1", "sourceSE2" )
    self.op.TargetSE = "%s,%s" % ( "targetSE1", "targetSE2" )

    self.File = File()
    self.File.LFN = '/cta/file1'
    self.File.Size = 2L
    self.File.Checksum = '011300a2'
    self.File.ChecksumType = "adler32"
    self.op.addFile( self.File )

    self.req = Request()
    self.req.addOperation( self.op )
    self.mr = MoveReplica( self.op )

    self.mr.dm = MagicMock()
    self.mr.fc = MagicMock()
Ejemplo n.º 4
0
    def setUp(self):
      self.op = Operation()
      self.op.Type = "MoveFile"
      self.op.SourceSE = "%s,%s" % ( "sourceSE1", "sourceSE2" )
      self.op.TargetSE = "%s,%s" % ( "targetSE1", "targetSE2" )

      self.File = File()
      self.File.LFN = '/cta/file1'
      self.File.Size = 2L
      self.File.Checksum = '011300a2'
      self.File.ChecksumType = "adler32"
      self.op.addFile( self.File )

      self.req = Request()
      self.req.addOperation( self.op )
      self.mr = MoveReplica( self.op )

      self.mr.dm = MagicMock()
      self.mr.fc = MagicMock()
Ejemplo n.º 5
0
class MoveReplicaFailure( ReqOpsTestCase ):

  def setUp( self ):
    self.op = Operation()
    self.op.Type = "MoveReplica"
    self.op.SourceSE = "%s,%s" % ( "sourceSE1", "sourceSE2" )
    self.op.TargetSE = "%s,%s" % ( "targetSE1", "targetSE2" )

    self.File = File()
    self.File.LFN = '/cta/file1'
    self.File.Size = 2L
    self.File.Checksum = '011300a2'
    self.File.ChecksumType = "adler32"
    self.op.addFile( self.File )

    self.req = Request()
    self.req.addOperation( self.op )
    self.mr = MoveReplica( self.op )

    self.mr.dm = MagicMock()
    self.mr.fc = MagicMock()
    self.mr.ci = MagicMock()

  def test__dmTransfer( self ):

    successful = {}
    for sourceSE in self.op.sourceSEList:
      successful[sourceSE] = 'dips://' + sourceSE.lower() + ':9148/DataManagement/StorageElement' + self.File.LFN

    res = {'OK': True, 'Value': ({self.File.LFN: successful}, [])}
    self.mr.ci._getCatalogReplicas.return_value = res

    res = {'OK': True, 'Value': {'MissingAllReplicas': {}, 'NoReplicas': {}, 'MissingReplica': {}, 'SomeReplicasCorrupted': {}, 'AllReplicasCorrupted': {}}}
    self.mr.ci.compareChecksum.return_value = res

    res =  {'OK': True, 'Value': {'Successful': {}, 'Failed': {self.File.LFN : 'Unable to replicate file'}}}
    self.mr.dm.replicateAndRegister.return_value = res

    res = self.mr.dmTransfer( self.File )
    self.assertFalse( res['OK'] )

    self.assertEqual( self.mr.operation.__files__[0].Status, 'Waiting' )
    self.assertEqual( self.mr.operation.Status, 'Waiting' )
    self.assertEqual( self.mr.request.Status, 'Waiting' )


  def test__dmRemoval( self ):

    res =  {'OK': True, 'Value': {'Successful': {}, 'Failed': {self.File.LFN: 'Write access not permitted for this credential'}}}
    self.mr.dm.removeReplica.return_value = res

    toRemoveDict = {self.File.LFN: self.File}
    targetSEs = self.op.sourceSEList

    res = self.mr.dmRemoval( toRemoveDict, targetSEs )
    self.assertTrue( res['OK'] )

    resvalue = dict( [ ( targetSE, 'Write access not permitted for this credential' ) for targetSE in targetSEs ] )
    self.assertEqual( res['Value'], {self.File.LFN: resvalue} )

    self.assertEqual( self.mr.operation.__files__[0].Status, 'Waiting' )
    self.assertEqual( self.mr.operation.Status, 'Waiting' )
    self.assertEqual( self.mr.request.Status, 'Waiting' )
Ejemplo n.º 6
0
class MoveReplicaFailure( ReqOpsTestCase ):

    def setUp( self ):
      self.op = Operation()
      self.op.Type = "MoveReplica"
      self.op.SourceSE = "%s,%s" % ( "sourceSE1", "sourceSE2" )
      self.op.TargetSE = "%s,%s" % ( "targetSE1", "targetSE2" )

      self.File = File()
      self.File.LFN = '/cta/file1'
      self.File.Size = 2L
      self.File.Checksum = '011300a2'
      self.File.ChecksumType = "adler32"
      self.op.addFile( self.File )

      self.req = Request()
      self.req.addOperation( self.op )
      self.mr = MoveReplica( self.op )

      self.mr.dm = MagicMock()
      self.mr.fc = MagicMock()
      self.mr.ci = MagicMock()

    def test__dmTransfer( self ):

      successful = {}
      for sourceSE in self.op.sourceSEList:
        successful[sourceSE] = 'dips://' + sourceSE.lower() + ':9148/DataManagement/StorageElement' + self.File.LFN

      res = {'OK': True, 'Value': ({self.File.LFN: successful}, [])}
      self.mr.ci._getCatalogReplicas.return_value = res

      res = {'OK': True, 'Value': {'MissingAllReplicas': {}, 'NoReplicas': {}, 'MissingReplica': {}, 'SomeReplicasCorrupted': {}, 'AllReplicasCorrupted': {}}}
      self.mr.ci.compareChecksum.return_value = res

      res =  {'OK': True, 'Value': {'Successful': {}, 'Failed': {self.File.LFN : 'Unable to replicate file'}}}
      self.mr.dm.replicateAndRegister.return_value = res

      res = self.mr.dmTransfer( self.File )
      self.assertFalse( res['OK'] )

      self.assertEqual( self.mr.operation.__files__[0].Status, 'Waiting' )
      self.assertEqual( self.mr.operation.Status, 'Waiting' )
      self.assertEqual( self.mr.request.Status, 'Waiting' )


    def test__dmRemoval( self ):

      res =  {'OK': True, 'Value': {'Successful': {}, 'Failed': {self.File.LFN: 'Write access not permitted for this credential'}}}
      self.mr.dm.removeReplica.return_value = res

      toRemoveDict = {self.File.LFN: self.File}
      targetSEs = self.op.sourceSEList

      res = self.mr.dmRemoval( toRemoveDict, targetSEs )
      self.assertTrue( res['OK'] )

      resvalue = dict( [ ( targetSE, 'Write access not permitted for this credential' ) for targetSE in targetSEs ] )
      self.assertEqual( res['Value'], {self.File.LFN: resvalue} )

      self.assertEqual( self.mr.operation.__files__[0].Status, 'Waiting' )
      self.assertEqual( self.mr.operation.Status, 'Waiting' )
      self.assertEqual( self.mr.request.Status, 'Waiting' )
Ejemplo n.º 7
0
class MoveReplicaFailure(ReqOpsTestCase):
    def setUp(self):
        self.op = Operation()
        self.op.Type = "MoveReplica"
        self.op.SourceSE = "%s,%s" % ("sourceSE1", "sourceSE2")
        self.op.TargetSE = "%s,%s" % ("targetSE1", "targetSE2")

        self.File = File()
        self.File.LFN = "/cta/file1"
        self.File.Size = 2
        self.File.Checksum = "011300a2"
        self.File.ChecksumType = "adler32"
        self.op.addFile(self.File)

        self.req = Request()
        self.req.addOperation(self.op)
        self.mr = MoveReplica(self.op)

        self.mr.dm = MagicMock()
        self.mr.fc = MagicMock()
        self.mr.ci = MagicMock()

    def test__dmTransfer(self):

        successful = {}
        for sourceSE in self.op.sourceSEList:
            successful[sourceSE] = "dips://" + sourceSE.lower() + ":9148/DataManagement/StorageElement" + self.File.LFN

        res = {"OK": True, "Value": ({self.File.LFN: successful}, [])}
        self.mr.ci._getCatalogReplicas.return_value = res

        res = {
            "OK": True,
            "Value": {
                "MissingAllReplicas": {},
                "NoReplicas": {},
                "MissingReplica": {},
                "SomeReplicasCorrupted": {},
                "AllReplicasCorrupted": {},
            },
        }
        self.mr.ci.compareChecksum.return_value = res

        res = {"OK": True, "Value": {"Successful": {}, "Failed": {self.File.LFN: "Unable to replicate file"}}}
        self.mr.dm.replicateAndRegister.return_value = res

        res = self.mr.dmTransfer(self.File)
        self.assertFalse(res["OK"])

        self.assertEqual(self.mr.operation.__files__[0].Status, "Waiting")
        self.assertEqual(self.mr.operation.Status, "Waiting")
        self.assertEqual(self.mr.request.Status, "Waiting")

    def test__dmRemoval(self):

        res = {
            "OK": True,
            "Value": {"Successful": {}, "Failed": {self.File.LFN: "Write access not permitted for this credential"}},
        }
        self.mr.dm.removeReplica.return_value = res

        toRemoveDict = {self.File.LFN: self.File}
        targetSEs = self.op.sourceSEList

        res = self.mr.dmRemoval(toRemoveDict, targetSEs)
        self.assertTrue(res["OK"])

        resvalue = dict([(targetSE, "Write access not permitted for this credential") for targetSE in targetSEs])
        self.assertEqual(res["Value"], {self.File.LFN: resvalue})

        self.assertEqual(self.mr.operation.__files__[0].Status, "Waiting")
        self.assertEqual(self.mr.operation.Status, "Waiting")
        self.assertEqual(self.mr.request.Status, "Waiting")