def test_03_replicationTree( self ): """ test replication tree """ sHandler = StrategyHandler( self.configPath, self.bands, self.channels, self.failedFiles ) tree = sHandler.replicationTree( ["CERN-USER", "CNAF-USER"], ["PIC-USER", "RAL-USER"], 1000L, "MinimiseTotalWait" ) self.assertEqual( tree["OK"], True ) tree = tree["Value"] self.assertEqual( tree, { 48L: {'Ancestor': 14L, 'Strategy': 'MinimiseTotalWait', 'DestSE': 'PIC-USER', 'SourceSE': 'RAL-USER'}, 14L: {'Ancestor': False, 'Strategy': 'MinimiseTotalWait', 'DestSE': 'RAL-USER', 'SourceSE': 'CNAF-USER'}})
def test_03_replicationTree(self): """ test replication tree """ sHandler = StrategyHandler(self.configPath, self.bands, self.channels, self.failedFiles) tree = sHandler.replicationTree(["CERN-USER", "CNAF-USER"], ["PIC-USER", "RAL-USER"], 1000L, "MinimiseTotalWait") self.assertEqual(tree["OK"], True) tree = tree["Value"] self.assertEqual( tree, { 48L: { 'Ancestor': 14L, 'Strategy': 'MinimiseTotalWait', 'DestSE': 'PIC-USER', 'SourceSE': 'RAL-USER' }, 14L: { 'Ancestor': False, 'Strategy': 'MinimiseTotalWait', 'DestSE': 'RAL-USER', 'SourceSE': 'CNAF-USER' } })
def test_02_Strategies( self ): """ test strategies """ sHandler = StrategyHandler( self.configPath, self.bands, self.channels, self.failedFiles ) tree = sHandler.minimiseTotalWait( [ 'CERN-DST' ], ['RAL-HEP-DST'] ) print tree ## simple - wrong args tree = sHandler.simple( ["CERN-USER", "PIC-USER"], ["CNAF-USER"] ) self.assertEqual( tree["OK"], False ) self.assertEqual( tree["Message"], "simple: wrong argument supplied for sourceSEs, only one sourceSE allowed" ) ## simple - no channel defined tree = sHandler.simple( [ "CERN-USER" ], ["FOO-USER"] ) self.assertEqual( tree["OK"], False ) self.assertEqual( tree["Message"], "FTSGraph: unable to find FTS channel between 'CERN-USER' and 'FOO-USER'" ) ## simple - channel used twice tree = sHandler.simple( ["CERN-USER"], [ "CNAF-DST", "CNAF-USER" ] ) self.assertEqual( tree["OK"], False ) self.assertEqual( tree["Message"], "simple: unable to create replication tree, channel 'CERN-CNAF' can't be used twice") ## simple - OK tree = sHandler.simple( ["CERN-USER"], ["PIC-USER" ] ) self.assertEqual( tree["OK"], True ) self.assertEqual( tree["Value"], {6L: {'Ancestor': False, 'Strategy': 'Simple', 'DestSE': 'PIC-USER', 'SourceSE': 'CERN-USER'}} )
def test_01_ctor( self ): """ constructor + update test """ sHandler = StrategyHandler( self.configPath, self.bands, self.channels, self.failedFiles ) self.assertEqual( isinstance( sHandler, StrategyHandler), True ) gr = sHandler.setup( self.channels, self.bands, self.failedFiles ) self.assertEqual( gr["OK"], True ) self.assertEqual( isinstance( sHandler.ftsGraph, Graph ), True ) ## change one channel self.channels[1]["Size"] = 100000000L gr = sHandler.setup( self.channels, self.bands, self.failedFiles ) self.assertEqual( gr["OK"], True ) self.assertEqual( isinstance( sHandler.ftsGraph, Graph ), True ) ## get channel channel = sHandler.ftsGraph.findChannel( "CERN-USER", "CERN-USER" ) self.assertEqual( channel["OK"], True ) self.assertEqual( channel["Value"].channelName, "CERN-CERN" ) self.assertEqual( channel["Value"].size, self.channels[1]["Size"] )