def test01Create( self ): """ test create tables and views """ db = FTSDB() createTables = db.createTables( ["FTSSite", "FTSFile", "FTSJob"], True ) self.assertEqual( createTables["OK"], True, "tables creation error: %s" % createTables.get( "Message", "" ) ) createViews = db.createViews( True ) self.assertEqual( createViews["OK"], True, "views creation error: %s" % createViews.get( "Message" , "" ) )
def test03FTSHistory( self ): """ history view """ return db = FTSDB() ret = db.getFTSHistory() self.assertEqual( ret["OK"], True, "getFTSHistory failed" ) for ftsHistory in ret["Value"]: self.assertEqual( isinstance( ftsHistory, FTSHistoryView ), True, "getFTSHistory wrong instance" )
def test03FTSHistory(self): """ history view """ return db = FTSDB() ret = db.getFTSHistory() self.assertEqual(ret["OK"], True, "getFTSHistory failed") for ftsHistory in ret["Value"]: self.assertEqual(isinstance(ftsHistory, FTSHistoryView), True, "getFTSHistory wrong instance")
def test01Create(self): """ test create tables and views """ db = FTSDB() createTables = db.createTables(["FTSSite", "FTSFile", "FTSJob"], True) self.assertEqual( createTables["OK"], True, "tables creation error: %s" % createTables.get("Message", "")) createViews = db.createViews(True) self.assertEqual( createViews["OK"], True, "views creation error: %s" % createViews.get("Message", ""))
def initializeHandler(cls, serviceInfoDict): """ initialize handler """ try: cls.ftsDB = FTSDB() except RuntimeError, error: gLogger.exception(error) return S_ERROR(error)
def test04GetFTSIDs( self ): """ get ids """ return db = FTSDB() ftsJobIDs = db.getFTSJobIDs( [ "Submitted" ] ) self.assertEqual( ftsJobIDs["OK"], True, "getFTSJobIDs error" ) self.assertEqual( len( ftsJobIDs["Value"] ), self.submitted, "getFTSJobIDs wrong value returned" ) ftsFileIDs = db.getFTSFileIDs( ["Waiting"] ) self.assertEqual( ftsFileIDs["OK"], True, "getFTSFileIDs error" ) self.assertEqual( type( ftsFileIDs["Value"] ), list, "getFTSFileIDs wrong value returned" ) ftsFileList = db.getFTSFileList( ["Waiting.*" ] ) self.assertEqual( ftsFileList["OK"], True, "getFTSFileList error" ) self.assertEqual( type( ftsFileList["Value"] ), list, "fgetFTSFileList wrong value returned" ) print "read ", len( ftsFileList["Value"] ), " records"
def initializeHandler(cls, serviceInfoDict): """ initialize handler """ try: from DIRAC.DataManagementSystem.DB.FTSDB import FTSDB cls.__ftsDB = FTSDB() except RuntimeError, error: gLogger.exception(error) return S_ERROR(error)
def test05Delete( self ): """ delete files and jobs """ return db = FTSDB() for i in range( 1, 301 ): delete = db.deleteFTSFile( i ) self.assertEqual( delete["OK"], True, "deleleFTSFile failed" ) # for i in range( 1, 201 ): # delete = db.deleteFTSJob( i ) # self.assertEqual( delete["OK"], True, "deleleFTSJob failed" ) summary = db.getDBSummary() self.assertEqual( summary["OK"], True, "getDBSummary failed" ) self.assertEqual( "FTSJob" in summary["Value"], True, "getDBSummary FTSJob missing" ) self.assertEqual( "FTSFile" in summary["Value"], True, "getDBSummary FTSFile missing" ) self.assertEqual( "FTSHistory" in summary["Value"], True, "getDBSummary FTSHistory missing" ) self.assertEqual( "FTSSite" in summary["Value"], True, "getDBSummary FTSSite missing" )
def test04GetFTSIDs(self): """ get ids """ return db = FTSDB() ftsJobIDs = db.getFTSJobIDs(["Submitted"]) self.assertEqual(ftsJobIDs["OK"], True, "getFTSJobIDs error") self.assertEqual(len(ftsJobIDs["Value"]), self.submitted, "getFTSJobIDs wrong value returned") ftsFileIDs = db.getFTSFileIDs(["Waiting"]) self.assertEqual(ftsFileIDs["OK"], True, "getFTSFileIDs error") self.assertEqual(type(ftsFileIDs["Value"]), list, "getFTSFileIDs wrong value returned") ftsFileList = db.getFTSFileList(["Waiting.*"]) self.assertEqual(ftsFileList["OK"], True, "getFTSFileList error") self.assertEqual(type(ftsFileList["Value"]), list, "fgetFTSFileList wrong value returned") print "read ", len(ftsFileList["Value"]), " records"
def test05Delete(self): """ delete files and jobs """ return db = FTSDB() for i in range(1, 301): delete = db.deleteFTSFile(i) self.assertEqual(delete["OK"], True, "deleleFTSFile failed") # for i in range( 1, 201 ): # delete = db.deleteFTSJob( i ) # self.assertEqual( delete["OK"], True, "deleleFTSJob failed" ) summary = db.getDBSummary() self.assertEqual(summary["OK"], True, "getDBSummary failed") self.assertEqual("FTSJob" in summary["Value"], True, "getDBSummary FTSJob missing") self.assertEqual("FTSFile" in summary["Value"], True, "getDBSummary FTSFile missing") self.assertEqual("FTSHistory" in summary["Value"], True, "getDBSummary FTSHistory missing") self.assertEqual("FTSSite" in summary["Value"], True, "getDBSummary FTSSite missing")
def test02PutGetDelete( self ): """ put, get, peek methods """ db = FTSDB() print "put site" for ftsSite in self.ftsSites: put = db.putFTSSite( ftsSite ) self.assertEqual( put["OK"], True, "putFTSSite failed" ) put = db.putFTSSite( ftsSite ) self.assertEqual( put["OK"], False, "re-putFTSSite failed" ) return print "getFTSSite" for i, ftsSite in enumerate( self.ftsSites ): get = db.getFTSSite( i + 1 ) self.assertEqual( get["OK"], True, "getFTSSite failed" ) self.assertEqual( isinstance( get["Value"], FTSSite ), True, "getFTSSite wrong value returned" ) print "getFTSSiteList" getFTSSitesList = db.getFTSSitesList() self.assertEqual( getFTSSitesList["OK"], True, "getFTSSitesList failed" ) for item in getFTSSitesList["Value"]: self.assertEqual( isinstance( item, FTSSite ), True, "getFTSSitesList wrong value returned" ) print "putFile" for ftsFile in self.ftsFiles: put = db.putFTSFile( ftsFile ) self.assertEqual( put["OK"], True, "putFTSFile failed" ) print "peekFile" for i in range( 1, 101 ): peek = db.peekFTSFile( i ) self.assertEqual( peek["OK"], True, "peekFTSFile failed" ) self.assertEqual( isinstance( peek["Value"], FTSFile ), True, "peekFTSFile wrong value" ) print "getFile" for i in range( 1, 101 ): get = db.getFTSFile( i ) self.assertEqual( get["OK"], True, "getFTSFile failed" ) self.assertEqual( isinstance( get["Value"], FTSFile ), True, "getFTSFile wrong value" ) print "putJob" for ftsJob in self.ftsJobs: put = db.putFTSJob( ftsJob ) self.assertEqual( put["OK"], True, "putFTSJob failed" ) print "peekJob" for i in range( 1, 101 ): peek = db.peekFTSJob( i ) self.assertEqual( peek["OK"], True, "peekFTSJob failed" ) self.assertEqual( isinstance( peek["Value"], FTSJob ), True, "peekFTSJob wrong value returned" ) self.assertEqual( len( peek["Value"] ), 1, "peekFTSJob wrong number of files " ) print "getJob" for i in range( 1, 101 ): get = db.getFTSJob( i ) self.assertEqual( get["OK"], True, "getFTSJob failed" ) self.assertEqual( isinstance( get["Value"], FTSJob ), True, "getFTSJob wrong value returned" ) self.assertEqual( len( get["Value"] ), 1, "getFTSJob wrong number of files" ) print "duSummary" summary = db.getDBSummary() self.assertEqual( summary["OK"], True, "getDBSummary failed" ) self.assertEqual( "FTSJob" in summary["Value"], True, "getDBSummary FTSJob missing" ) self.assertEqual( "FTSFile" in summary["Value"], True, "getDBSummary FTSFile missing" ) self.assertEqual( "FTSHistory" in summary["Value"], True, "getDBSummary FTSHistory missing" ) self.assertEqual( "FTSSite" in summary["Value"], True, "getDBSummary FTSSite missing" )
def test02PutGetDelete(self): """ put, get, peek methods """ db = FTSDB() print "put site" for ftsSite in self.ftsSites: put = db.putFTSSite(ftsSite) self.assertEqual(put["OK"], True, "putFTSSite failed") put = db.putFTSSite(ftsSite) self.assertEqual(put["OK"], False, "re-putFTSSite failed") return print "getFTSSite" for i, ftsSite in enumerate(self.ftsSites): get = db.getFTSSite(i + 1) self.assertEqual(get["OK"], True, "getFTSSite failed") self.assertEqual(isinstance(get["Value"], FTSSite), True, "getFTSSite wrong value returned") print "getFTSSiteList" getFTSSitesList = db.getFTSSitesList() self.assertEqual(getFTSSitesList["OK"], True, "getFTSSitesList failed") for item in getFTSSitesList["Value"]: self.assertEqual(isinstance(item, FTSSite), True, "getFTSSitesList wrong value returned") print "putFile" for ftsFile in self.ftsFiles: put = db.putFTSFile(ftsFile) self.assertEqual(put["OK"], True, "putFTSFile failed") print "peekFile" for i in range(1, 101): peek = db.peekFTSFile(i) self.assertEqual(peek["OK"], True, "peekFTSFile failed") self.assertEqual(isinstance(peek["Value"], FTSFile), True, "peekFTSFile wrong value") print "getFile" for i in range(1, 101): get = db.getFTSFile(i) self.assertEqual(get["OK"], True, "getFTSFile failed") self.assertEqual(isinstance(get["Value"], FTSFile), True, "getFTSFile wrong value") print "putJob" for ftsJob in self.ftsJobs: put = db.putFTSJob(ftsJob) self.assertEqual(put["OK"], True, "putFTSJob failed") print "peekJob" for i in range(1, 101): peek = db.peekFTSJob(i) self.assertEqual(peek["OK"], True, "peekFTSJob failed") self.assertEqual(isinstance(peek["Value"], FTSJob), True, "peekFTSJob wrong value returned") self.assertEqual(len(peek["Value"]), 1, "peekFTSJob wrong number of files ") print "getJob" for i in range(1, 101): get = db.getFTSJob(i) self.assertEqual(get["OK"], True, "getFTSJob failed") self.assertEqual(isinstance(get["Value"], FTSJob), True, "getFTSJob wrong value returned") self.assertEqual(len(get["Value"]), 1, "getFTSJob wrong number of files") print "duSummary" summary = db.getDBSummary() self.assertEqual(summary["OK"], True, "getDBSummary failed") self.assertEqual("FTSJob" in summary["Value"], True, "getDBSummary FTSJob missing") self.assertEqual("FTSFile" in summary["Value"], True, "getDBSummary FTSFile missing") self.assertEqual("FTSHistory" in summary["Value"], True, "getDBSummary FTSHistory missing") self.assertEqual("FTSSite" in summary["Value"], True, "getDBSummary FTSSite missing")