Exemplo n.º 1
0
    def setUp(self):
        """c'tor
    :param self: self reference
    """

        self.fixSURLEqTURLPlugin = FixSURLEqTURLPlugin()
        self.fixSURLEqTURLPlugin.__requestDBMySQL = Mock(spec=RequestDBMySQL)
Exemplo n.º 2
0
  def setUp( self ):
    """c'tor
    :param self: self reference
    """

    self.fixSURLEqTURLPlugin = FixSURLEqTURLPlugin()
    self.fixSURLEqTURLPlugin.__requestDBMySQL = Mock(spec=RequestDBMySQL)
Exemplo n.º 3
0
class FixSURLEqTURLPluginTests(unittest.TestCase):
  """
  .. class:: FixSURLEqTURLPluginTests
  
  """

  def setUp( self ):
    """c'tor
    :param self: self reference
    """

    self.fixSURLEqTURLPlugin = FixSURLEqTURLPlugin()
    self.fixSURLEqTURLPlugin.__requestDBMySQL = Mock(spec=RequestDBMySQL)

    
  def test_NoRequestNorSubRequest( self ):
    """
    SubRequestID = 0, no SubRequest nor Request in RequestDB
    """
    ## mocking 
    self.fixSURLEqTURLPlugin.requestDBMySQL().selectFileSourceSURLEqTargetSURL = Mock()
    self.fixSURLEqTURLPlugin.requestDBMySQL().selectFileSourceSURLEqTargetSURL.return_value = { 
      "OK" : True, 
      "Value" : ( 1558187, 
                  "/lhcb/MC/MC10/ALLSTREAMS.DST/00009359/0000/00009359_00000005_1.allstreams.dst",
                  17, 
                  "GRIDKA_MC_M-DST",
                  "GRIDKA_MC-DST",
                  0 ) }
    self.fixSURLEqTURLPlugin.requestDBMySQL().countLFNInFiles = Mock()
    self.fixSURLEqTURLPlugin.requestDBMySQL().countLFNInFiles.return_value = {
      "OK" : True,
      "Value" : ( 1, )
      }
    self.fixSURLEqTURLPlugin.requestDBMySQL().deleteFileAndChannel = Mock()
    self.fixSURLEqTURLPlugin.requestDBMySQL().deleteFileAndChannel.return_value = {
      "OK" : True,
      "Value" : tuple()
      }

    ## excute plugin
    ret = self.fixSURLEqTURLPlugin.execute()
    self.assertEqual( ret, {'OK': True, 'Value': ()} )

  def test_RequestPresent( self ):
    """
    Request is there
    """

    ## mocking
    self.fixSURLEqTURLPlugin.requestDBMySQL().selectFileSourceSURLEqTargetSURL = Mock()
    self.fixSURLEqTURLPlugin.requestDBMySQL().selectFileSourceSURLEqTargetSURL.return_value = { 
      "OK" : True, 
      "Value" : ( 1610538,
                  "/lhcb/MC/MC10/ALLSTREAMS.DST/00009422/0000/00009422_00000171_1.allstreams.dst",
                  17, 
                  "GRIDKA_MC_M-DST",
                  "GRIDKA_MC-DST", 
                  2259916 ) }


    self.fixSURLEqTURLPlugin.requestDBMySQL().getRequestForSubRequest = Mock()
    self.fixSURLEqTURLPlugin.requestDBMySQL().getRequestForSubRequest.return_value = getRequest()
    self.fixSURLEqTURLPlugin.replicaManager().getReplicas = Mock()
    self.fixSURLEqTURLPlugin.replicaManager().getReplicas.return_value = { 
      "OK" : True,
      "Value" : { 'Failed': {},
                  'Successful': {'/lhcb/MC/MC10/ALLSTREAMS.DST/00009422/0000/00009422_00000171_1.allstreams.dst': {'CERN_MC_M-DST': 'srm://srm-lhcb.cern.ch/castor/cern.ch/grid/lhcb/MC/MC10/ALLSTREAMS.DST/00009422/0000/00009422_00000171_1.allstreams.dst',
                                                                                                  'GRIDKA_MC_M-DST': 'srm://gridka-dCache.fzk.de/pnfs/gridka.de/lhcb/MC/MC10/ALLSTREAMS.DST/00009422/0000/00009422_00000171_1.allstreams.dst'}}}
      }
    self.fixSURLEqTURLPlugin.requestDBMySQL().selectChannelIDSourceSURLTargetSURL = Mock()
    self.fixSURLEqTURLPlugin.requestDBMySQL().selectChannelIDSourceSURLTargetSURL.return_value = { 
      "OK" : True,
      "Value" : {
        3 : { "SourceSE" : "CERN_MC_M-DST",
              "TargetSE" : "GRIDKA_MC_M-DST", 
              "Status" : "Done", 
              "SourceSURLEqTargetSURL" : False },
        17 : { "SourceSE" : "GRIDKA_MC_M-DST",
               "TargetSE" : "GRIDKA_MC-DST", 
               "Status" : "Waiting", 
               "SourceSURLEqTargetSURL" : True }
          }
        } 

    self.fixSURLEqTURLPlugin.requestClient().updateRequest = Mock()
    self.fixSURLEqTURLPlugin.requestClient().updateRequest.return_value = { "OK" : True, 
                                                                            "Value" : None }

    ## execute plugin
    ret = self.fixSURLEqTURLPlugin.execute()
    self.assertEqual( ret, { "OK": True, "Value" : "" })
Exemplo n.º 4
0
class FixSURLEqTURLPluginTests(unittest.TestCase):
    """
  .. class:: FixSURLEqTURLPluginTests
  
  """
    def setUp(self):
        """c'tor
    :param self: self reference
    """

        self.fixSURLEqTURLPlugin = FixSURLEqTURLPlugin()
        self.fixSURLEqTURLPlugin.__requestDBMySQL = Mock(spec=RequestDBMySQL)

    def test_NoRequestNorSubRequest(self):
        """
    SubRequestID = 0, no SubRequest nor Request in RequestDB
    """
        ## mocking
        self.fixSURLEqTURLPlugin.requestDBMySQL(
        ).selectFileSourceSURLEqTargetSURL = Mock()
        self.fixSURLEqTURLPlugin.requestDBMySQL(
        ).selectFileSourceSURLEqTargetSURL.return_value = {
            "OK":
            True,
            "Value":
            (1558187,
             "/lhcb/MC/MC10/ALLSTREAMS.DST/00009359/0000/00009359_00000005_1.allstreams.dst",
             17, "GRIDKA_MC_M-DST", "GRIDKA_MC-DST", 0)
        }
        self.fixSURLEqTURLPlugin.requestDBMySQL().countLFNInFiles = Mock()
        self.fixSURLEqTURLPlugin.requestDBMySQL(
        ).countLFNInFiles.return_value = {
            "OK": True,
            "Value": (1, )
        }
        self.fixSURLEqTURLPlugin.requestDBMySQL().deleteFileAndChannel = Mock()
        self.fixSURLEqTURLPlugin.requestDBMySQL(
        ).deleteFileAndChannel.return_value = {
            "OK": True,
            "Value": tuple()
        }

        ## excute plugin
        ret = self.fixSURLEqTURLPlugin.execute()
        self.assertEqual(ret, {'OK': True, 'Value': ()})

    def test_RequestPresent(self):
        """
    Request is there
    """

        ## mocking
        self.fixSURLEqTURLPlugin.requestDBMySQL(
        ).selectFileSourceSURLEqTargetSURL = Mock()
        self.fixSURLEqTURLPlugin.requestDBMySQL(
        ).selectFileSourceSURLEqTargetSURL.return_value = {
            "OK":
            True,
            "Value":
            (1610538,
             "/lhcb/MC/MC10/ALLSTREAMS.DST/00009422/0000/00009422_00000171_1.allstreams.dst",
             17, "GRIDKA_MC_M-DST", "GRIDKA_MC-DST", 2259916)
        }

        self.fixSURLEqTURLPlugin.requestDBMySQL(
        ).getRequestForSubRequest = Mock()
        self.fixSURLEqTURLPlugin.requestDBMySQL(
        ).getRequestForSubRequest.return_value = getRequest()
        self.fixSURLEqTURLPlugin.replicaManager().getReplicas = Mock()
        self.fixSURLEqTURLPlugin.replicaManager().getReplicas.return_value = {
            "OK": True,
            "Value": {
                'Failed': {},
                'Successful': {
                    '/lhcb/MC/MC10/ALLSTREAMS.DST/00009422/0000/00009422_00000171_1.allstreams.dst':
                    {
                        'CERN_MC_M-DST':
                        'srm://srm-lhcb.cern.ch/castor/cern.ch/grid/lhcb/MC/MC10/ALLSTREAMS.DST/00009422/0000/00009422_00000171_1.allstreams.dst',
                        'GRIDKA_MC_M-DST':
                        'srm://gridka-dCache.fzk.de/pnfs/gridka.de/lhcb/MC/MC10/ALLSTREAMS.DST/00009422/0000/00009422_00000171_1.allstreams.dst'
                    }
                }
            }
        }
        self.fixSURLEqTURLPlugin.requestDBMySQL(
        ).selectChannelIDSourceSURLTargetSURL = Mock()
        self.fixSURLEqTURLPlugin.requestDBMySQL(
        ).selectChannelIDSourceSURLTargetSURL.return_value = {
            "OK": True,
            "Value": {
                3: {
                    "SourceSE": "CERN_MC_M-DST",
                    "TargetSE": "GRIDKA_MC_M-DST",
                    "Status": "Done",
                    "SourceSURLEqTargetSURL": False
                },
                17: {
                    "SourceSE": "GRIDKA_MC_M-DST",
                    "TargetSE": "GRIDKA_MC-DST",
                    "Status": "Waiting",
                    "SourceSURLEqTargetSURL": True
                }
            }
        }

        self.fixSURLEqTURLPlugin.requestClient().updateRequest = Mock()
        self.fixSURLEqTURLPlugin.requestClient().updateRequest.return_value = {
            "OK": True,
            "Value": None
        }

        ## execute plugin
        ret = self.fixSURLEqTURLPlugin.execute()
        self.assertEqual(ret, {"OK": True, "Value": ""})