Exemplo n.º 1
0
    def test_01_oneMasterNormal(self, mk_getSelectedCatalogs,
                                mk_getEligibleCatalogs):
        """Test behavior with one master and only standard read methods"""

        fc = FileCatalog(catalogs=[
            'c1_True_True_True_2_0_2_0', 'c2_False_True_True_3_0_1_0'
        ])

        # Test a write method which is not in the master catalog
        with self.assertRaises(AttributeError):
            fc.write4('/lhcb/toto')

        # Test a write method which works for everybody
        lfn = '/lhcb/toto'
        res = fc.write1(lfn)
        self.assertTrue(res['OK'])
        self.assertTrue(lfn in res['Value']['Successful'])
        self.assertEqual(sorted(['c1', 'c2']),
                         sorted(res['Value']['Successful'][lfn].keys()))
        self.assertTrue(not res['Value']['Failed'])

        # Test a write method that only the master has
        lfn = '/lhcb/toto'
        res = fc.write2(lfn)
        self.assertTrue(res['OK'])
        self.assertTrue(lfn in res['Value']['Successful'])
        self.assertEqual(['c1'], res['Value']['Successful'][lfn].keys())
        self.assertTrue(not res['Value']['Failed'])

        # Test a write method that makes an error for master
        # We should get an error
        lfn = '/lhcb/c1/Error'
        res = fc.write1(lfn)
        self.assertTrue(not res['OK'])

        # Test a write method that fails for master
        # The lfn should be in failed and only attempted for the master
        lfn = '/lhcb/c1/Failed'
        res = fc.write1(lfn)
        self.assertTrue(res['OK'])
        self.assertTrue(not res['Value']['Successful'])
        self.assertEqual(['c1'], res['Value']['Failed'][lfn].keys())

        # Test a write method that makes an error for non master
        # The lfn should be in failed for non master and successful for the master
        lfn = '/lhcb/c2/Error'
        res = fc.write1(lfn)
        self.assertTrue(res['OK'])
        self.assertEqual(['c1'], res['Value']['Successful'][lfn].keys())
        self.assertEqual(['c2'], res['Value']['Failed'][lfn].keys())

        # Test a write method that fails for non master
        # The lfn should be in failed for non master and successful for the master
        lfn = '/lhcb/c2/Failed'
        res = fc.write1(lfn)
        self.assertTrue(res['OK'])
        self.assertEqual(['c1'], res['Value']['Successful'][lfn].keys())
        self.assertEqual(['c2'], res['Value']['Failed'][lfn].keys())
Exemplo n.º 2
0
  def test_01_oneMasterNormal( self, mk_getSelectedCatalogs, mk_getEligibleCatalogs ):
    """Test behavior with one master and only standard read methods"""


    fc = FileCatalog( catalogs = ['c1_True_True_True_2_0_2_0', 'c2_False_True_True_3_0_1_0'] )

    # Test a write method which is not in the master catalog
    with self.assertRaises( AttributeError ):
      fc.write4( '/lhcb/toto' )

    # Test a write method which works for everybody
    lfn = '/lhcb/toto'
    res = fc.write1( lfn )
    self.assert_( res['OK'] )
    self.assert_( lfn in res['Value']['Successful'] )
    self.assertEqual( sorted( ['c1', 'c2'] ), sorted( res['Value']['Successful'][lfn].keys() ) )
    self.assert_( not res['Value']['Failed'] )


    # Test a write method that only the master has
    lfn = '/lhcb/toto'
    res = fc.write2( lfn )
    self.assert_( res['OK'] )
    self.assert_( lfn in res['Value']['Successful'] )
    self.assertEqual( ['c1'], res['Value']['Successful'][lfn].keys() )
    self.assert_( not res['Value']['Failed'] )

    # Test a write method that makes an error for master
    # We should get an error
    lfn = '/lhcb/c1/Error'
    res = fc.write1( lfn )
    self.assert_( not res['OK'] )

    # Test a write method that fails for master
    # The lfn should be in failed and only attempted for the master
    lfn = '/lhcb/c1/Failed'
    res = fc.write1( lfn )
    self.assert_( res['OK'] )
    self.assert_( not res['Value']['Successful'] )
    self.assertEqual( ['c1'], res['Value']['Failed'][lfn].keys() )

    # Test a write method that makes an error for non master
    # The lfn should be in failed for non master and successful for the master
    lfn = '/lhcb/c2/Error'
    res = fc.write1( lfn )
    self.assert_( res['OK'] )
    self.assertEqual( ['c1'], res['Value']['Successful'][lfn].keys() )
    self.assertEqual( ['c2'], res['Value']['Failed'][lfn].keys() )


    # Test a write method that fails for non master
    # The lfn should be in failed for non master and successful for the master
    lfn = '/lhcb/c2/Failed'
    res = fc.write1( lfn )
    self.assert_( res['OK'] )
    self.assertEqual( ['c1'], res['Value']['Successful'][lfn].keys() )
    self.assertEqual( ['c2'], res['Value']['Failed'][lfn].keys() )
Exemplo n.º 3
0
    def test_01_oneMasterNormal(self, mk_getSelectedCatalogs, mk_getEligibleCatalogs):
        """Test behavior with one master and only standard read methods"""

        fc = FileCatalog(catalogs=["c1_True_True_True_2_0_2_0", "c2_False_True_True_3_0_1_0"])

        # Test a write method which is not in the master catalog
        with self.assertRaises(AttributeError):
            fc.write4("/lhcb/toto")

        # Test a write method which works for everybody
        lfn = "/lhcb/toto"
        res = fc.write1(lfn)
        self.assertTrue(res["OK"])
        self.assertTrue(lfn in res["Value"]["Successful"])
        self.assertEqual(sorted(["c1", "c2"]), sorted(res["Value"]["Successful"][lfn]))
        self.assertTrue(not res["Value"]["Failed"])

        # Test a write method that only the master has
        lfn = "/lhcb/toto"
        res = fc.write2(lfn)
        self.assertTrue(res["OK"])
        self.assertTrue(lfn in res["Value"]["Successful"])
        self.assertEqual(["c1"], sorted(res["Value"]["Successful"][lfn]))
        self.assertTrue(not res["Value"]["Failed"])

        # Test a write method that makes an error for master
        # We should get an error
        lfn = "/lhcb/c1/Error"
        res = fc.write1(lfn)
        self.assertTrue(not res["OK"])

        # Test a write method that fails for master
        # The lfn should be in failed and only attempted for the master
        lfn = "/lhcb/c1/Failed"
        res = fc.write1(lfn)
        self.assertTrue(res["OK"])
        self.assertTrue(not res["Value"]["Successful"])
        self.assertEqual(["c1"], sorted(res["Value"]["Failed"][lfn]))

        # Test a write method that makes an error for non master
        # The lfn should be in failed for non master and successful for the master
        lfn = "/lhcb/c2/Error"
        res = fc.write1(lfn)
        self.assertTrue(res["OK"])
        self.assertEqual(["c1"], sorted(res["Value"]["Successful"][lfn]))
        self.assertEqual(["c2"], sorted(res["Value"]["Failed"][lfn]))

        # Test a write method that fails for non master
        # The lfn should be in failed for non master and successful for the master
        lfn = "/lhcb/c2/Failed"
        res = fc.write1(lfn)
        self.assertTrue(res["OK"])
        self.assertEqual(["c1"], sorted(res["Value"]["Successful"][lfn]))
        self.assertEqual(["c2"], sorted(res["Value"]["Failed"][lfn]))
Exemplo n.º 4
0
    def test_03_noLFN(self, mk_getSelectedCatalogs, mk_getEligibleCatalogs):
        """Test the no_lfn methods"""

        fc = FileCatalog(catalogs=["c1_True_True_True_2_0_2_1", "c2_False_True_True_3_0_2_1"])

        # all good
        res = fc.write2("/lhcb/toto")
        self.assertTrue(res["OK"])
        self.assertEqual(res["Value"], "yeah")

        # Fail in the master
        res = fc.write2("/lhcb/c1")
        self.assertTrue(not res["OK"])
        self.assertTrue("Value" not in res)

        # Fail in the non master
        res = fc.write2("/lhcb/c2")
        self.assertTrue(res["OK"])
        self.assertTrue("Value" in res)
        self.assertEqual(res["Value"], "yeah")
Exemplo n.º 5
0
  def test_03_noLFN( self, mk_getSelectedCatalogs, mk_getEligibleCatalogs ):
    """ Test the no_lfn methods """


    fc = FileCatalog( catalogs = ['c1_True_True_True_2_0_2_1', 'c2_False_True_True_3_0_2_1'] )

    # all good
    res = fc.write2( "/lhcb/toto" )
    self.assert_( res['OK'] )
    self.assertEqual( res['Value'], 'yeah' )

    # Fail in the master
    res = fc.write2( "/lhcb/c1" )
    self.assert_( not res['OK'] )
    self.assert_( not 'Value' in res )

    # Fail in the non master
    res = fc.write2( "/lhcb/c2" )
    self.assert_( res['OK'] )
    self.assert_( 'Value' in res )
    self.assertEqual( res['Value'], 'yeah' )